@gobob/bob-sdk 3.3.4 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ import { BitcoinSigner } from '../types';
2
+ interface OkxWalletProvider {
3
+ send: (params: {
4
+ from: string;
5
+ to: string;
6
+ value: string;
7
+ memo: string;
8
+ }) => Promise<{
9
+ txhash: string;
10
+ }>;
11
+ }
12
+ export declare class OkxWalletAdapter implements BitcoinSigner {
13
+ walletProvider: OkxWalletProvider;
14
+ constructor(walletProvider: OkxWalletProvider);
15
+ sendBitcoin({ from, to, value, opReturn, isSignet, }: {
16
+ from: string;
17
+ to: string;
18
+ value: string;
19
+ opReturn: string;
20
+ isSignet: boolean;
21
+ }): Promise<string>;
22
+ }
23
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OkxWalletAdapter = void 0;
4
+ const esplora_1 = require("../../esplora");
5
+ const wallet_1 = require("../../wallet");
6
+ class OkxWalletAdapter {
7
+ walletProvider;
8
+ constructor(walletProvider) {
9
+ this.walletProvider = walletProvider;
10
+ }
11
+ async sendBitcoin({ from, to, value, opReturn, isSignet, }) {
12
+ const { txhash } = await this.walletProvider.send({
13
+ from,
14
+ to,
15
+ value,
16
+ memo: opReturn,
17
+ });
18
+ const network = (0, wallet_1.getAddressInfo)(to, isSignet).network;
19
+ const esploraClient = new esplora_1.EsploraClient(network);
20
+ return esploraClient.getTransactionHex(txhash);
21
+ }
22
+ }
23
+ exports.OkxWalletAdapter = OkxWalletAdapter;
24
+ //# sourceMappingURL=okx-wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"okx-wallet.js","sourceRoot":"","sources":["../../../src/gateway/adapters/okx-wallet.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAE9C,yCAA8C;AAO9C,MAAa,gBAAgB;IACzB,cAAc,CAAoB;IAElC,YAAY,cAAiC;QACzC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EACd,IAAI,EACJ,EAAE,EACF,KAAK,EACL,QAAQ,EACR,QAAQ,GAOX;QACG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YAC9C,IAAI;YACJ,EAAE;YACF,KAAK;YACL,IAAI,EAAE,QAAQ;SACjB,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,IAAA,uBAAc,EAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC;QACrD,MAAM,aAAa,GAAG,IAAI,uBAAa,CAAC,OAAO,CAAC,CAAC;QACjD,OAAO,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CACJ;AA/BD,4CA+BC"}
@@ -0,0 +1,21 @@
1
+ import { BitcoinSigner } from '../types';
2
+ interface ReownWalletProvider {
3
+ signPSBT: (params: {
4
+ psbt: string;
5
+ broadcast: boolean;
6
+ signInputs: Array<{
7
+ index: number;
8
+ address: string;
9
+ sighashTypes: number[];
10
+ }>;
11
+ }) => Promise<{
12
+ psbt: string;
13
+ }>;
14
+ }
15
+ export declare class ReownWalletAdapter implements BitcoinSigner {
16
+ walletProvider: ReownWalletProvider;
17
+ userAddress: string;
18
+ constructor(walletProvider: ReownWalletProvider, userAddress: string);
19
+ signAllInputs(psbtBase64: string): Promise<string>;
20
+ }
21
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReownWalletAdapter = void 0;
4
+ const btc_signer_1 = require("@scure/btc-signer");
5
+ const base_1 = require("@scure/base");
6
+ class ReownWalletAdapter {
7
+ walletProvider;
8
+ userAddress;
9
+ constructor(walletProvider, userAddress) {
10
+ this.walletProvider = walletProvider;
11
+ this.userAddress = userAddress;
12
+ }
13
+ async signAllInputs(psbtBase64) {
14
+ const unsignedTx = btc_signer_1.Transaction.fromPSBT(base_1.base64.decode(psbtBase64));
15
+ const inputLength = unsignedTx.inputsLength;
16
+ const inputsToSign = Array.from({ length: inputLength }, (_, i) => i);
17
+ const result = await this.walletProvider.signPSBT({
18
+ psbt: psbtBase64,
19
+ broadcast: false,
20
+ signInputs: inputsToSign.map((input) => ({ index: input, address: this.userAddress, sighashTypes: [0] })),
21
+ });
22
+ const signedTx = btc_signer_1.Transaction.fromPSBT(base_1.base64.decode(result.psbt));
23
+ signedTx.finalize();
24
+ return signedTx.hex;
25
+ }
26
+ }
27
+ exports.ReownWalletAdapter = ReownWalletAdapter;
28
+ //# sourceMappingURL=reown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reown.js","sourceRoot":"","sources":["../../../src/gateway/adapters/reown.ts"],"names":[],"mappings":";;;AAAA,kDAAgD;AAEhD,sCAAqC;AAWrC,MAAa,kBAAkB;IAC3B,cAAc,CAAsB;IACpC,WAAW,CAAS;IAEpB,YAAY,cAAmC,EAAE,WAAmB;QAChE,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,UAAkB;QAClC,MAAM,UAAU,GAAG,wBAAW,CAAC,QAAQ,CAAC,aAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QAGnE,MAAM,WAAW,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAGtE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;YAC9C,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAC5G,CAAC,CAAC;QAGH,MAAM,QAAQ,GAAG,wBAAW,CAAC,QAAQ,CAAC,aAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,QAAQ,CAAC,GAAG,CAAC;IACxB,CAAC;CACJ;AA5BD,gDA4BC"}
@@ -1,51 +1,53 @@
1
- import { Account, Address, PublicClient, Transport, Chain as ViemChain, WalletClient } from 'viem';
2
- import { EnrichedToken, ExecuteQuoteParams, ExecuteStakeParam, GatewayQuote, GatewayStartOrder, GatewayStrategyContract, GatewayTokensInfo, GetQuoteParams, OfframpBumpFeeParams, OfframpCreateOrderParams, OfframpLiquidity, OfframpOrder, OfframpOrderStatus, OfframpQuote, OfframpUnlockFundsParams, OnrampOrder, StakeParams, StakeTransactionParams, Token } from './types';
1
+ import { Account, Address, PublicClient, Transport, Chain as ViemChain, WalletClient, Hash } from 'viem';
2
+ import { BitcoinSigner, BumpFeeParams, EnrichedToken, ExecuteQuoteParams, GatewayQuote, GatewayStartOrder, GatewayStrategyContract, GatewayTokensInfo, GetQuoteParams, OfframpCreateOrderParams, OfframpLiquidity, OfframpOrder, OfframpOrderStatus, OfframpQuote, OnrampOrder, StrategyParams, Token, UnlockOrderParams } from './types';
3
3
  export declare const MAINNET_GATEWAY_BASE_URL = "https://gateway-api-mainnet.gobob.xyz";
4
4
  export declare const SIGNET_GATEWAY_BASE_URL = "https://gateway-api-signet.gobob.xyz";
5
5
  export declare const ORDER_DEADLINE_IN_SECONDS: number;
6
+ interface EvmWalletClientParams {
7
+ walletClient: WalletClient<Transport, ViemChain, Account>;
8
+ publicClient: PublicClient<Transport>;
9
+ }
10
+ interface AllWalletClientParams extends EvmWalletClientParams {
11
+ btcSigner?: BitcoinSigner;
12
+ }
6
13
  export declare class GatewayApiClient {
7
14
  private chain;
8
- private baseUrl;
9
15
  private strategy;
10
16
  private isSignet;
11
- constructor(chainName: 'mainnet' | 'signet' | 'bob', options?: {
17
+ constructor(chainId: number, options?: {
12
18
  rpcUrl?: string;
13
19
  });
20
+ private get baseUrl();
14
21
  private get chainId();
15
- getChains(): string[];
16
22
  getQuote(params: GetQuoteParams): Promise<{
17
23
  params: GetQuoteParams;
18
24
  onrampQuote?: GatewayQuote & GatewayTokensInfo;
19
25
  offrampQuote?: OfframpQuote;
20
26
  }>;
21
27
  getOnrampQuote(params: GetQuoteParams): Promise<GatewayQuote & GatewayTokensInfo>;
28
+ getOfframpQuote(params: GetQuoteParams): Promise<OfframpQuote>;
22
29
  fetchOfframpRegistryAddress(): Promise<Address>;
23
30
  fetchOfframpLiquidity(token: string): Promise<OfframpLiquidity>;
24
- fetchOfframpQuote(token: Address, amountInToken: bigint): Promise<OfframpQuote>;
31
+ fetchOfframpQuote(token: Address, amountInToken: bigint, userAddress: Address): Promise<OfframpQuote>;
25
32
  createOfframpOrder(quote: OfframpQuote, params: GetQuoteParams): Promise<OfframpCreateOrderParams>;
26
- bumpFeeForOfframpOrder(orderId: bigint): Promise<OfframpBumpFeeParams>;
27
- unlockOfframpOrder(orderId: bigint, receiver: Address): Promise<OfframpUnlockFundsParams>;
33
+ bumpFeeForOfframpOrder({ orderId, walletClient, publicClient, }: BumpFeeParams & EvmWalletClientParams): Promise<Hash>;
34
+ unlockOfframpOrder({ orderId, receiver, walletClient, publicClient, }: UnlockOrderParams & EvmWalletClientParams): Promise<Hash>;
28
35
  getOfframpOrders(userAddress: Address): Promise<OfframpOrder[]>;
29
36
  private getBumpFeeRequirement;
30
37
  canOrderBeUnlocked(status: OfframpOrderStatus, orderTimestamp: number, offrampRegistryAddress: Address): Promise<boolean>;
31
38
  private fetchOfframpOrder;
32
- startOrder(gatewayQuote: GatewayQuote, params: GetQuoteParams): Promise<GatewayStartOrder>;
33
- executeQuote(executeQuoteParams: ExecuteQuoteParams, { walletClient, publicClient, btcSigner, }: {
34
- walletClient: WalletClient<Transport, ViemChain, Account>;
35
- publicClient: PublicClient<Transport>;
36
- btcSigner?: {
37
- signAllInputs: (psbtBase64: string) => Promise<string>;
38
- };
39
- }): Promise<string>;
40
- executeStake(params: ExecuteStakeParam, walletClient: WalletClient<Transport, ViemChain, Account>, publicClient: PublicClient<Transport>): Promise<`0x${string}`>;
41
- finalizeOrder(uuid: string, bitcoinTxOrId: string): Promise<string>;
39
+ startOnrampOrder(gatewayQuote: GatewayQuote, params: GetQuoteParams): Promise<GatewayStartOrder>;
40
+ executeQuote({ quote: executeQuoteParams, walletClient, publicClient, btcSigner, }: {
41
+ quote: ExecuteQuoteParams;
42
+ } & AllWalletClientParams): Promise<string>;
43
+ executeStrategy({ walletClient, publicClient, ...params }: StrategyParams & EvmWalletClientParams): Promise<`0x${string}`>;
44
+ finalizeOnrampOrder(uuid: string, bitcoinTxOrId: string): Promise<string>;
42
45
  getOnrampOrders(userAddress: Address): Promise<OnrampOrder[]>;
43
46
  getStrategies(): Promise<GatewayStrategyContract[]>;
44
47
  getTokenAddresses(includeStrategies?: boolean): Promise<Address[]>;
45
48
  getTokens(includeStrategies?: boolean): Promise<Token[]>;
46
49
  private getPrices;
47
50
  getEnrichedTokens(includeStrategies?: boolean): Promise<EnrichedToken[]>;
48
- buildStake(stakeParams: StakeParams): Promise<StakeTransactionParams>;
49
51
  getOrders(userAddress: Address): Promise<Array<{
50
52
  type: 'onramp';
51
53
  order: OnrampOrder;
@@ -55,3 +57,4 @@ export declare class GatewayApiClient {
55
57
  }>>;
56
58
  private fetchGet;
57
59
  }
60
+ export {};