Commit bde794d5 authored by XFT's avatar XFT
Browse files

.

parent 67aa780a
Pipeline #28 failed with stages
in 0 seconds
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ConnectWalletComponent } from './connect-wallet.component';
describe('ConnectWalletComponent', () => {
let component: ConnectWalletComponent;
let fixture: ComponentFixture<ConnectWalletComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ConnectWalletComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ConnectWalletComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef } from '@angular/core';
import { Store } from '@ngrx/store';
import { delay, Observable } from 'rxjs';
import { DisconnectWallet, GetTokensRequest } from '../../core/actions';
import { generateJazzicon } from '../../core/helpers';
import { selectAccountAddress } from '../../core/selectors';
import { WalletService } from '../../core/services/wallet.service';
@Component({
selector: 'os-connect-wallet',
templateUrl: './connect-wallet.component.html',
styleUrls: ['./connect-wallet.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ConnectWalletComponent implements OnInit {
public accountAddress$: Observable<string>;
constructor(
private readonly _store: Store,
private readonly _cdr: ChangeDetectorRef,
private readonly _walletService: WalletService,
private readonly _elementRef: ElementRef,
) {
this.accountAddress$ = this._store.select(selectAccountAddress);
}
public ngOnInit(): void {
this.accountAddress$
.pipe(
delay(100),
)
.subscribe((accountAddress) => {
const element = this._elementRef.nativeElement.querySelector('div.p-button');
const identicon = generateJazzicon(accountAddress);
if (identicon && element) {
const previousIdenticon = element.querySelector(':scope > div');
if (previousIdenticon) {
element.removeChild(previousIdenticon);
}
identicon.style.marginLeft = '12px';
element.appendChild(identicon);
this._store.dispatch(GetTokensRequest());
}
});
}
public async onConnectWalletClick(): Promise<void> {
this._walletService.clearCachedProvider();
await this._walletService.connect();
window.location.reload();
}
public async onDisconnectWalletClick(): Promise<void> {
this._walletService.clearCachedProvider();
this._store.dispatch(DisconnectWallet());
}
}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveComponentModule } from '@ngrx/component';
import { ButtonModule } from 'primeng/button';
import { PipesModule } from '../../core/pipes';
import { ConnectWalletComponent } from './connect-wallet.component';
@NgModule({
declarations: [
ConnectWalletComponent,
],
exports: [
ConnectWalletComponent,
],
imports: [
CommonModule,
ButtonModule,
PipesModule,
ReactiveComponentModule,
]
})
export class ConnectWalletModule {
}
import { Params } from '@angular/router';
import { createAction, props } from '@ngrx/store';
import { RouterParams } from './index';
import { ApproveParams, OutputParamsBalance, TransactionHash } from './interfaces/contract-service-methods';
export const SetRouterParams = createAction(
'[@offshift] SET_ROUTER_PARAMS',
props<{ url: string; params: RouterParams; queryParams: Params }>(),
);
export const DisconnectWallet = createAction(
'[@offshift] DISCONNECT_WALLET_REQUEST',
);
export const SetAccountAddress = createAction(
'[@offshift] SET_ACCOUNT_ADDRESS',
props<{ accountAddress: string }>(),
);
export const SetApproveRequest = createAction(
'[@offshift] SET_APPROVE_REQUEST',
);
export const SetApproveSuccess = createAction(
'[@offshift] SET_APPROVE_SUCCESS',
props<{ payload: ApproveParams }>(),
);
export const SetApproveFailure = createAction(
'[@offshift] SET_APPROVE_FAILURE',
props<{ error: any }>(),
);
export const GetTokensRequest = createAction(
'[@offshift] GET_TOKENS_REQUEST',
);
export const GetTokensSuccess = createAction(
'[@offshift] GET_TOKENS_SUCCESS',
props<{ payload: TransactionHash }>(),
);
export const GetTokensFailure = createAction(
'[@offshift] GET_TOKENS_FAILURE',
props<{ error: any }>(),
);
export const GetXFTBalanceRequest = createAction(
'[@offshift] GET_XFT_BALANCE_REQUEST',
);
export const GetXFTBalanceSuccess = createAction(
'[@offshift] GET_XFT_BALANCE_SUCCESS',
props<{ xftBalance: string }>(),
);
export const GetXFTBalanceFailure = createAction(
'[@offshift] GET_XFT_BALANCE_FAILURE',
props<{ error: any }>(),
);
export const GetUSDBalanceRequest = createAction(
'[@offshift] GET_USD_BALANCE_REQUEST',
);
export const GetUSDBalanceSuccess = createAction(
'[@offshift] GET_USD_BALANCE_SUCCESS',
props<{ usdBalance: string }>(),
);
export const GetUSDBalanceFailure = createAction(
'[@offshift] GET_USD_BALANCE_FAILURE',
props<{ error: any }>(),
);
export const GetLatestPriceRequest = createAction(
'[@offshift] GET_LATEST_PRICE_REQUEST',
props<{ aggregator: number }>(),
);
export const GetLatestPriceSuccess = createAction(
'[@offshift] GET_LATEST_PRICE_SUCCESS',
props<{ assetPrice: { price: string, decimals: number } }>(),
);
export const GetLatestPriceFailure = createAction(
'[@offshift] GET_LATEST_PRICE_FAILURE',
props<{ error: any }>(),
);
export const GetAllowanceRequest = createAction(
'[@offshift] GET_ALLOWANCE_REQUEST',
);
export const GetAllowanceSuccess = createAction(
'[@offshift] GET_ALLOWANCE_SUCCESS',
props<{ allowance: string }>(),
);
export const GetAllowanceFailure = createAction(
'[@offshift] GET_ALLOWANCE_FAILURE',
props<{ error: any }>(),
);
export const GetBalancesRequest = createAction(
'[@offshift] GET_BALANCES_REQUEST',
);
export const GetBalancesSuccess = createAction(
'[@offshift] GET_BALANCES_SUCCESS',
props<{ balances: OutputParamsBalance[] }>(),
);
export const GetBalancesFailure = createAction(
'[@offshift] GET_BALANCES_FAILURE',
props<{ error: any }>(),
);
import { Actions } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { CoreState } from './reducer';
import { selectContext } from './selectors';
export abstract class BaseEffects {
protected context$: Observable<CoreState>;
protected constructor(
protected store: Store,
protected actions$: Actions,
) {
this.context$ = this.store.select(selectContext);
}
}
import { Injectable } from '@angular/core';
import { Router, RouterStateSnapshot } from '@angular/router';
import { Actions, createEffect, ofType, concatLatestFrom } from '@ngrx/effects';
import { ROUTER_NAVIGATED, RouterNavigatedAction } from '@ngrx/router-store';
import { Action, Store } from '@ngrx/store';
import { catchError, from, map, mergeMap, Observable, of, withLatestFrom } from 'rxjs';
import { environment } from '../../environments/environment';
import {
GetAllowanceFailure,
GetAllowanceRequest,
GetAllowanceSuccess, GetBalancesFailure, GetBalancesRequest, GetBalancesSuccess,
GetLatestPriceFailure,
GetLatestPriceRequest, GetLatestPriceSuccess,
GetTokensFailure,
GetTokensRequest,
GetTokensSuccess,
GetXFTBalanceFailure, GetXFTBalanceRequest,
GetXFTBalanceSuccess,
GetUSDBalanceFailure, GetUSDBalanceRequest,
GetUSDBalanceSuccess,
SetAccountAddress,
SetRouterParams,
} from './actions';
import { BaseEffects } from './base.effects';
import { RouterParamsSerializer } from './router-params.serializer';
import { ContractService } from './services/contract.service';
@Injectable()
export class CoreEffects extends BaseEffects {
constructor(
store: Store,
actions$: Actions,
private _router: Router,
private _contractService: ContractService,
private _routerParamsSerializer: RouterParamsSerializer,
) {
super(store, actions$);
}
public routerNavigated$: Observable<Action> = createEffect(() => {
return this.actions$.pipe(
ofType(ROUTER_NAVIGATED),
map(({ payload }: RouterNavigatedAction<RouterStateSnapshot>) => {
const { url, params, queryParams } = this._routerParamsSerializer.serialize(payload.routerState);
return SetRouterParams({ url, params, queryParams });
}),
);
});
public init$: Observable<Action> = createEffect(() => {
return this.actions$
.pipe(
ofType(SetAccountAddress),
mergeMap(({ accountAddress: currentUser }) => {
this.store.dispatch(GetXFTBalanceRequest());
this.store.dispatch(GetAllowanceRequest());
this.store.dispatch(GetBalancesRequest());
return this._contractService.init({
currentUser,
rawURL: environment.infuraUrl,
balanceContractAddress: environment.balanceContractAddress,
priceContractAddress: environment.priceContractAddress,
tokenContractAddress: environment.tokenContractAddress,
})
.pipe(
catchError(() => of(null)),
);
}),
);
}, { dispatch: false });
public xftBalance$: Observable<Action> = createEffect(() => {
return this.actions$
.pipe(
ofType(GetXFTBalanceRequest),
concatLatestFrom(() => this.context$),
mergeMap(([action, { accountAddress }]) => {
if(!accountAddress) {
return of(GetXFTBalanceSuccess({ xftBalance: undefined }));
}
return from(this._contractService.xftBalance(accountAddress))
.pipe(
map((xftBalance) => GetXFTBalanceSuccess({ xftBalance })),
catchError((error) => of(GetXFTBalanceFailure({ error }))),
);
}),
);
});
public usdBalance$: Observable<Action> = createEffect(() => {
return this.actions$
.pipe(
ofType(GetUSDBalanceRequest),
concatLatestFrom(() => this.context$),
mergeMap(([action, { accountAddress }]) => {
if(!accountAddress) {
return of(GetUSDBalanceSuccess({ usdBalance: undefined }));
}
return from(this._contractService.usdBalance(accountAddress))
.pipe(
map((usdBalance) => GetUSDBalanceSuccess({ usdBalance })),
catchError((error) => of(GetUSDBalanceFailure({ error }))),
);
}),
);
});
public getLatestPriceRequest$: Observable<Action> = createEffect(() => {
return this.actions$
.pipe(
ofType(GetLatestPriceRequest),
mergeMap(({ aggregator }) => {
return from(this._contractService.getLatestPrice(aggregator))
.pipe(
map((assetPrice) => {
return GetLatestPriceSuccess({ assetPrice });
}),
catchError((error) => {
return of(GetLatestPriceFailure({ error }));
}),
);
}),
);
});
public getBalancesRequest$: Observable<Action> = createEffect(() => {
return this.actions$
.pipe(
ofType(GetBalancesRequest),
concatLatestFrom(() => this.context$),
mergeMap(([action, { accountAddress: address }]) => {
return this._contractService.balances({ address })
.pipe(
map((balances) => {
return GetBalancesSuccess({ balances });
}),
catchError((error) => {
return of(GetBalancesFailure({ error }));
}),
);
}),
);
});
}
export enum EthEvents {
AccountsChanged = 'accountsChanged',
ChainChanged = 'chainChanged',
Connect = 'connect',
Disconnect = 'disconnect',
Message = 'message',
}
export enum EthMethods {
SwitchEthereumChain = 'wallet_switchEthereumChain',
AddEthereumChain = 'wallet_addEthereumChain',
}
export * from './tokens';
export * from './eth-events';
export * from './eth-methods';
export enum Tokens {
XFT = 'XFT',
zkBTC = 'zkBTC',
zkETH = 'zkETH',
zkXAU = 'zkXAU',
anonUSD = 'anonUSDM',
anonUSD100 = 'anonUSDM (100)',
anonUSD1000 = 'anonUSDM (1000)',
anonUSD10000 = 'anonUSDM (10000)'
}
export enum TokensAggregator {
XFT = 0,
USD = 1,
BTC = 2,
ETH = 3,
XAU = 4,
anonUSD100 = 5,
anonUSD1000 = 6,
anonUSD10000 = 7,
}
export enum TokensName {
XFT = 'XFT',
USD = 'USD',
BTC = 'BTC',
ETH = 'ETH',
XAU = 'XAU',
anonUSD100 = 'anonUSD100',
anonUSD1000 = 'anonUSD1000',
anonUSD10000 = 'anonUSD10000',
}
export const TOKENS_AGGREGATOR_MAP = {
[TokensName.XFT]: TokensAggregator.XFT,
[TokensName.USD]: TokensAggregator.USD,
[TokensName.BTC]: TokensAggregator.BTC,
[TokensName.ETH]: TokensAggregator.ETH,
[TokensName.XAU]: TokensAggregator.XAU,
[TokensName.anonUSD100]: TokensAggregator.anonUSD100,
[TokensName.anonUSD1000]: TokensAggregator.anonUSD1000,
[TokensName.anonUSD10000]: TokensAggregator.anonUSD10000,
};
export const TOKENS_NAME_MAP = {
[Tokens.XFT]: TokensName.XFT,
[TokensName.USD]: TokensName.USD,
[TokensName.BTC]: TokensName.BTC,
[TokensName.ETH]: TokensName.ETH,
[TokensName.XAU]: TokensName.XAU,
[TokensName.anonUSD100]: TokensName.anonUSD100, // aUSD 100
[TokensName.anonUSD1000]: TokensName.anonUSD1000, // aUSD 1000
[TokensName.anonUSD10000]: TokensName.anonUSD10000, // aUSD 10000
};
export const TOKENS_STRING_MAP: {[key: string]: Tokens} = {
"Tokens.XFT": Tokens.XFT,
"Tokens.anonUSD100": Tokens.anonUSD100,
"Tokens.anonUSD1000": Tokens.anonUSD1000,
"Tokens.anonUSD10000": Tokens.anonUSD10000
}
export const TOKENS_NAME_STRING_MAP: {[key: string]: TokensName} = {
"TokensName.XFT": TokensName.XFT,
"TokensName.USD": TokensName.USD,
"TokensName.BTC": TokensName.BTC,
"TokensName.ETH": TokensName.ETH,
"TokensName.XAU": TokensName.XAU,
"TokensName.anonUSD100": TokensName.anonUSD100,
"TokensName.anonUSD1000": TokensName.anonUSD1000,
"TokensName.anonUSD10000": TokensName.anonUSD10000,
}
\ No newline at end of file
import { BigNumber } from 'bignumber.js';
import { Unit } from 'web3-utils';
import Web3 from 'web3';
export type BigNumberValue = BigNumber.Value;
export const BigNumberZD = BigNumber.clone({
DECIMAL_PLACES: 0,
ROUNDING_MODE: BigNumber.ROUND_DOWN,
});
export function valueToBigNumber(amount: BigNumberValue): BigNumber {
if (amount instanceof BigNumber) {
return amount;
}
return new BigNumber(amount || 0);
}
export function valueToZDBigNumber(amount: BigNumberValue): BigNumber {
return new BigNumberZD(amount);
}
const bn10 = new BigNumber(10);
const bn10PowLookup: { [key: number]: BigNumber } = {};
export function pow10(decimals: number): BigNumber {
if (!bn10PowLookup[decimals]) bn10PowLookup[decimals] = bn10.pow(decimals);
return bn10PowLookup[decimals];
}
export function normalize(value: BigNumberValue, decimals: number): string {
return normalizeBN(value, decimals).toString(10);
}
export function normalizeBN(value: BigNumberValue, decimals: number): BigNumber {
return valueToBigNumber(value).dividedBy(pow10(decimals));
}
export function valueToWei(value: BigNumberValue, decimals: number): string {
return valueToBigNumber(value).shiftedBy(decimals).toFixed(0);
}
export function fromWei(
amount: BigNumber.Value,
unit: Unit = 'ether',
): BigNumberValue {
return valueToBigNumber(Web3.utils.fromWei((amount || 0).toString(), unit));
}
export function toWei(
amount: string | BigNumber.Value,
unit: Unit = 'ether',
): string {
if (amount instanceof BigNumber) {
amount = amount.toString(10);
}
return Web3.utils.toWei((amount || 0).toString(), unit);
}
import { getAddress } from '@ethersproject/address';
// @ts-ignore
import jazzicon from '@metamask/jazzicon';
export function isTxHash(address: string): boolean {
return (/^0x([A-Fa-f0-9]{64})$/).test(address);
}
export function shortTxHash(address: string): string {
return [address.slice(0, 5), address.slice(-4)].join('...');
}
export function isAddress(value: string): string | false {
try {
return getAddress(value);
} catch {
return false;
}
}
export function shortAddress(address: string, chars = 4): string | null {
const parsed = isAddress(address);
if (!parsed) {
return null;
}
return `${parsed.substring(0, chars + 2)}...${parsed.substring(42 - chars)}`;
}
export function generateJazzicon(address: string, diameter = 20): HTMLDivElement | null {
const parsed = isAddress(address);
if (!parsed) {
return null;
}
return jazzicon(diameter, parseInt(address.slice(2, 10), 16));
}
import { Tokens, TokensName, TOKENS_STRING_MAP, TOKENS_NAME_STRING_MAP } from '../enums';
import { TokenType } from '../types';
import { shifters } from 'src/environments/shifters';
export * from './helpers';
export * from './bignumber';
export const TOKENS_MAP: { [key: string]: TokenType } = {}
for (const [key, value] of Object.entries(shifters)) {
TOKENS_MAP[key] = {
color: value["color"],
icon: value["icon"],
name: value["name"],
symbol: value["symbol"],
zkSymbol: value["zkSymbol"],
denom: BigInt(value["denom"]),
contract: value["contract"],
shifter: value["shifter"],
balance: null
}
}
\ No newline at end of file
import { Params } from '@angular/router';
import * as fromRouter from '@ngrx/router-store';
import { Action, ActionReducer, ActionReducerMap, MetaReducer } from '@ngrx/store';
import { reducer, CoreState } from './reducer';
export interface RouterParams {
}
export const initialRouterParamsState: RouterParams = {};
export type RouterQueryParams = Params;
export interface RouterState {
url: string;
params: RouterParams;
queryParams: RouterQueryParams;
}
export interface State {
router: fromRouter.RouterReducerState<any>;
context: CoreState;
}
export const reducers: ActionReducerMap<State> = {
router: fromRouter.routerReducer,
context: reducer,
};
export function disconnectWalletMetaReducer(reducer: ActionReducer<any, any>): ActionReducer<any, any> {
return function (state: State, action: Action): any {
return reducer(action.type === '[@offshift] DISCONNECT_WALLET_REQUEST' ? undefined : state, action);
};
}
export const metaReducers: MetaReducer<State>[] = [
disconnectWalletMetaReducer,
];
import { Contract } from 'web3-eth-contract';
import { CallReturn, SendReturn } from './callback';
import { BigNumberValue } from '../helpers';
import { TokensAggregator } from '../enums';
export interface RecipientCommitment {
commitment: {
x: string;
y: string;
};
asset: number;
}
export interface SchnorrSignatureSet {
message: string;
publicKey: {
x: string,
y: string,
};
ecR: {
x: string,
y: string,
};
s: string;
}
export interface EcNewCommitment {
x: string;
y: string;
}
export interface PkSum {
x: string;
y: string;
}
export interface BalanceContractMethods {
getLatestPrice(aggregator: number): CallReturn<any>;
deposit(
amountIn: BigNumberValue,
amountComm: BigNumberValue,
recipientCommitment: RecipientCommitment,
schnorrSignatureSet: SchnorrSignatureSet,
): SendReturn<any>;
withdraw(
amount: BigNumberValue,
commitmentId: BigNumberValue,
schnorrSignatureSet: SchnorrSignatureSet,
): SendReturn<any>;
groupCommitment(
commitmentIds: BigNumberValue[],
asset: TokensAggregator,
ecNewCommitment: EcNewCommitment,
pkSum: PkSum,
): SendReturn<any>;
}
export interface BalanceContract extends Contract {
methods: BalanceContractMethods;
}
export type MethodCallback = ((error: any, result: any) => void) | null;
export type SendCallback = (err: any, result: any) => void;
export interface CallReturn<T = any> {
call(obj?: { from: string }, cb?: MethodCallback): Promise<T>;
}
export interface SendReturn<T = any> {
call(obj?: { from: string }, cb?: MethodCallback): Promise<T>;
estimateGas(obj: { from: string, value?: string }, cb?: MethodCallback): Promise<number>;
send(obj: { from: string; gas?: number, value?: string }, cb?: MethodCallback): Promise<T>;
}
export type Optional<T> = T | undefined;
import { Contract } from 'web3-eth-contract';
import { CallReturn} from './callback';
export interface ChainlinkContractMethods {
latestAnswer(): CallReturn<any>
latestRoundData(): CallReturn<any>
decimals(): CallReturn<any>
}
export interface ChainlinkContract extends Contract {
methods: ChainlinkContractMethods;
}
import { Observable } from 'rxjs';
import { TokensName, Tokens } from 'src/app/core/enums';
export interface TransactionHash {
tx: string;
}
export interface InputParamsBalance {
address: string;
}
export interface BalanceAsset {
amount: string;
symbol: string;
USD: string;
XFT: string;
}
export interface BalanceCommitment {
amount: string;
id: string;
USD: string;
XFT: string;
}
export interface BalanceTypeAnon {
color: string,
icon: string,
symbol: string,
zkSymbol: string,
denom: BigInt,
commitments: Object[]
}
export interface EncryptedCommitment {
password: string;
commitment: string;
}
export interface DecryptedCommitment {
shifter: string;
commitment: string;
note: string;
denomination: string
}
export interface OutputParamsBalance {
asset: BalanceAsset;
commitments: DecryptedCommitment[];
icon?: string;
}
export interface ApproveParams {
amount: number;
senderPrivateKey: string;
spender: string;
}
export interface DepositParams {
amount: number;
currency: string;
senderPrivateKey: string;
}
export interface DepositAnonParams {
senderPrivateKey: string;
}
export interface GroupParams {
amount: string;
commitmentsId: string;
senderPrivateKey: string;
}
export interface RecipientTransferStartParams {
amount: string;
assetName: string;
recipientPrivateKey: string;
}
export interface RecipientTransferStartSetOut {
amount: string;
publicKey: string;
commitment: string;
pairR: string;
R: string;
address: string;
}
export interface TransferAggregationPubKeyOut {
aggrPubKeySet: string;
aggrR: string;
commitmentExcess: string;
pairRExcess: string;
pairRSender: string;
}
export interface TransferAggrPubKeyOut {
aggrPubKeySet: string;
aggrR: string;
commitmentExcess: string;
pairRSender: string;
pairRExcess: string;
}
export interface RecipientSignaturePart {
aggregatedPublicKey: string;
aggregatedR: string;
commitment: string;
L: string;
recipient: string;
valR: string;
}
export interface ComplexTransferParams {
amount: string;
commitmentExcess: string;
commitmentId: string;
commonParametersSign: string;
recipient: string;
recipientCommitment: string;
recipientPubKey: string;
recipientSignPart: string;
senderPrivateKey: string;
}
export interface WithdrawParams {
amount: string;
commitmentOldId: string;
senderPrivateKey: string;
}
export interface WithdrawAnonParams {
note: string;
_recipient: string;
senderPrivateKey: string;
}
export interface SimpleShiftParams {
amount: string;
recipient: string;
senderPrivateKey: string;
}
export interface GetTestTokensParams {
recipient: string;
}
export interface InputParamsPrice {
aggregator: string;
}
export interface InputParamsBurnCost {
pool: string;
denom: BigInt;
}
export interface InputParamsExchange {
aggrBase: string;
aggrQuote: string;
amount: string;
}
export interface OutputParamsPrice {
price: string;
decimal: number;
}
export interface InitData {
currentUser: string;
rawURL: string;
balanceContractAddress: string;
priceContractAddress: string;
tokenContractAddress: string;
}
export interface InputParamsDerive {
aggrBase: string;
aggrQuote: string;
}
export interface InputApproximateParams {
data: string;
amount: string;
}
export interface ContractServiceMethods {
approve(payload: ApproveParams): Observable<TransactionHash>;
complexPubkey(payload: TransferAggregationPubKeyOut): Observable<TransferAggrPubKeyOut>;
complexTransfer(payload: ComplexTransferParams): Observable<TransactionHash>;
deposit(payload: DepositParams): Observable<TransactionHash>;
depositAnon(payload: DepositAnonParams): Observable<TransactionHash>;
derivePrice(payload: InputParamsDerive): Observable<OutputParamsPrice>;
getPrice(payload: InputParamsPrice): Observable<OutputParamsPrice>;
getBurnCost(payload: InputParamsBurnCost): Observable<OutputParamsPrice>;
gettokens(payload: GetTestTokensParams): Observable<TransactionHash>;
group(payload: GroupParams): Observable<string>;
init(payload: InitData): Observable<void>;
recipientSignaturepart(payload: RecipientSignaturePart): Observable<string>;
recipientStartset(payload: RecipientTransferStartParams): Observable<RecipientTransferStartSetOut>;
safeApprove(payload: ApproveParams): Observable<TransactionHash>;
selectCommitments(payload: InputApproximateParams): Observable<any>;
simpleShift(payload: SimpleShiftParams): Observable<TransactionHash>;
withdraw(payload: WithdrawParams): Observable<TransactionHash>;
withdrawAnon(payload: WithdrawAnonParams): Observable<TransactionHash>;
}
import { EthEvents, EthMethods } from '../enums';
export interface EthChainParams {
chainId: string; // A 0x-prefixed hexadecimal string
chainName: string;
nativeCurrency: {
name: string;
symbol: string; // 2-6 characters long
decimals: number; // 18
};
rpcUrls: string[];
blockExplorerUrls?: string[];
iconUrls?: string[]; // Currently ignored.
}
export interface ConnectInfo {
chainId: string;
}
export interface ProviderMessage {
data: unknown;
type: string;
}
export interface ProviderRpcError extends Error {
code: number;
data?: unknown;
message: string;
}
export interface RequestArguments {
method: EthMethods | string;
params?: unknown[] | Record<string, unknown>;
}
export interface Ethereum {
isMetaMask: boolean;
selectedAddress: string;
chainId: string;
enable(): Promise<unknown>;
isConnected(): boolean;
on(eventName: EthEvents.AccountsChanged, handler: (accounts: string[]) => void): void;
on(eventName: EthEvents.ChainChanged, handler: (chainId: string) => void): void;
on(eventName: EthEvents.Connect, handler: (connectInfo: ConnectInfo) => void): void;
on(eventName: EthEvents.Disconnect, handler: (error: ProviderRpcError) => void): void;
on(eventName: EthEvents.Message, handler: (message: ProviderMessage) => void): void;
request<T = any>(args: RequestArguments): Promise<T>;
}
import { Contract } from 'web3-eth-contract';
import { CallReturn, SendReturn } from './callback';
export interface OracleContractMethods {
getCost(denom: BigInt, chainlinkFeed: string, xftPool: string): CallReturn<any>
getCostSimpleShift(denom: BigInt, chainlinkFeed: string, xftPool: string, tokenPool: string): CallReturn<any>
}
export interface OracleContract extends Contract {
methods: OracleContractMethods;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment