@rango-dev/provider-okx 0.63.1-next.3 → 0.63.1-next.5
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.
- package/dist/actions/ton.d.ts +1 -1
- package/dist/actions/ton.d.ts.map +1 -1
- package/dist/builders/ton.d.ts +1 -1
- package/dist/builders/ton.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/hooks/sui.d.ts +8 -0
- package/dist/hooks/sui.d.ts.map +1 -0
- package/dist/mod.d.ts +1 -1
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +4 -4
- package/dist/namespaces/sui.d.ts +4 -0
- package/dist/namespaces/sui.d.ts.map +1 -0
- package/dist/namespaces/ton/ton.d.ts +1 -1
- package/dist/namespaces/ton/ton.d.ts.map +1 -1
- package/dist/namespaces/ton/utils.d.ts +1 -1
- package/dist/namespaces/ton/utils.d.ts.map +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/signer.d.ts.map +1 -1
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +5 -2
- package/readme.md +9 -5
- package/src/actions/ton.ts +1 -1
- package/src/builders/ton.ts +1 -1
- package/src/constants.ts +13 -0
- package/src/hooks/sui.ts +46 -0
- package/src/namespaces/sui.ts +53 -0
- package/src/namespaces/ton/ton.ts +1 -4
- package/src/namespaces/ton/utils.ts +2 -2
- package/src/provider.ts +2 -0
- package/src/signer.ts +9 -0
- package/src/utils.ts +17 -1
package/dist/actions/ton.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TonProviderApi } from '../namespaces/ton/types.js';
|
|
2
2
|
import type { Context, FunctionWithContext } from '@hub3js/core';
|
|
3
|
-
import { type TonActions } from '@
|
|
3
|
+
import { type TonActions } from '@hub3js/tvm';
|
|
4
4
|
export declare function connect(getInstance: () => TonProviderApi): FunctionWithContext<TonActions['connect'], Context>;
|
|
5
5
|
export declare function canEagerConnect(getInstance: () => TonProviderApi): FunctionWithContext<TonActions['canEagerConnect'], Context>;
|
|
6
6
|
export declare function disconnect(getInstance: () => TonProviderApi): () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../src/actions/ton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../src/actions/ton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAa9C,wBAAgB,OAAO,CACrB,WAAW,EAAE,MAAM,cAAc,GAChC,mBAAmB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAwCrD;AAED,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,cAAc,GAChC,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAa7D;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,cAAc,uBAgB3D;AAED,eAAO,MAAM,UAAU;;;;CAA2C,CAAC"}
|
package/dist/builders/ton.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TonProviderApi } from '../namespaces/ton/types.js';
|
|
2
2
|
import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';
|
|
3
|
-
import { type TonActions } from '@
|
|
3
|
+
import { type TonActions } from '@hub3js/tvm';
|
|
4
4
|
export declare const changeAccountSubscriber: (getInstance: () => TonProviderApi) => ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>;
|
|
5
5
|
export declare const disconnectSubscriber: (getInstance: () => TonProviderApi) => ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>;
|
|
6
6
|
export declare const tonBuilders: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../src/builders/ton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../src/builders/ton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,KAAK,UAAU,EAAS,MAAM,aAAa,CAAC;AAUrD,eAAO,MAAM,uBAAuB,gBAAiB,MAAM,cAAc,wEAiBnE,CAAC;AAEP,eAAO,MAAM,oBAAoB,gBAAiB,MAAM,cAAc,wEAahE,CAAC;AAEP,eAAO,MAAM,WAAW;2CAlC6B,MAAM,cAAc;wCAmBvB,MAAM,cAAc;CAeM,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const TON_CONNECT_PROTOCOL_VERSION = 2;
|
|
|
5
5
|
export declare const TON_CONNECT_USER_REJECTED_CODE = 300;
|
|
6
6
|
export declare const TRON_OK_REQUEST_CODE = 200;
|
|
7
7
|
export declare const TRON_USER_REJECTION_CODE = 4001;
|
|
8
|
+
export declare const WALLET_NAME_IN_WALLET_STANDARD = "OKX Wallet";
|
|
8
9
|
export declare const OKX_WALLET_SUPPORTED_CHAINS: LegacyNetworks[];
|
|
9
10
|
export declare const metadata: ProviderMetadata;
|
|
10
11
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAehE,eAAO,MAAM,SAAS,QAAQ,CAAC;AAC/B,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAClD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,eAAO,MAAM,8BAA8B,eAAe,CAAC;AAE3D,eAAO,MAAM,2BAA2B,kBAcvC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,gBA6EtB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Subscriber, SubscriberCleanUp } from '@hub3js/core';
|
|
2
|
+
import type { ProviderAPI, SuiActions } from '@hub3js/sui';
|
|
3
|
+
declare function disconnectSubscriber(getInstance: () => ProviderAPI): [Subscriber<SuiActions>, SubscriberCleanUp<SuiActions>];
|
|
4
|
+
export declare const suiHooks: {
|
|
5
|
+
disconnectSubscriber: typeof disconnectSubscriber;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=sui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/hooks/sui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAU3D,iBAAS,oBAAoB,CAC3B,WAAW,EAAE,MAAM,WAAW,GAC7B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,CA8BzD;AAED,eAAO,MAAM,QAAQ;;CAA2B,CAAC"}
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const versions: () => readonly [readonly ["1.0.0", import("@hub3js/core").Provider<Record<"solana", import("@hub3js/solana").SolanaActions> & Record<"evm", import("@hub3js/evm").EvmActions> & Record<"utxo", import("@rango-dev/wallets-core/namespaces/utxo").UtxoActions> & Record<"ton", import("@
|
|
1
|
+
declare const versions: () => readonly [readonly ["1.0.0", import("@hub3js/core").Provider<Record<"solana", import("@hub3js/solana").SolanaActions> & Record<"evm", import("@hub3js/evm").EvmActions> & Record<"utxo", import("@rango-dev/wallets-core/namespaces/utxo").UtxoActions> & Record<"ton", import("@hub3js/tvm").TonActions> & Record<"tron", import("@rango-dev/wallets-core/namespaces/tron").TronActions> & Record<"sui", import("@hub3js/sui").SuiActions>>]];
|
|
2
2
|
export { versions };
|
|
3
3
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ,sbAC8C,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/mod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var On=Object.defineProperty;var e=(n,o)=>On(n,"name",{value:o,configurable:!0});import{defineVersions as nt}from"@hub3js/core/utils";import{ProviderBuilder as Zo}from"@hub3js/core";import{LegacyNetworks as c}from"@rango-dev/wallets-core/legacy";import{Networks as Vn}from"@rango-dev/wallets-shared";import{solanaBlockchain as Fn,tonBlockchain as Hn,tronBlockchain as zn}from"rango-types";import{EVM_NAMESPACE as Un,SOLANA_NAMESPACE as Xn,UTXO_NAMESPACE as jn,TON_NAMESPACE as Wn,TRON_NAMESPACE as Kn}from"@hub3js/namespaces";import{dynamicImportWithRefinedError as V,getNetworkInstance as E}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as qn,TransactionType as T}from"rango-types";import{DefaultSolanaSigner as xn}from"@rango-dev/signer-solana";import{SignerError as In,SignerErrorCode as Nn}from"rango-types";var b=class extends xn{static{e(this,"OKXSolanaSigner")}constructor(o){super(o)}async signMessage(o){try{let{signature:t}=await this.provider.request({method:"signMessage",params:{message:o}});return t}catch(t){throw new In(Nn.SIGN_TX_ERROR,void 0,t)}}};import{dynamicImportWithRefinedError as Bn}from"@rango-dev/wallets-shared";import{SignerError as P,SignerErrorCode as k,TonChainID as kn}from"rango-types";import{utils as B}from"@rango-dev/wallets-core/namespaces/ton";import{dynamicImportWithRefinedError as _n}from"@rango-dev/wallets-shared";function A(n){return!!n&&n.event==="connect"&&Array.isArray(n.payload?.items)}e(A,"isTonConnectEventSuccess");function Rn(n){return typeof n=="object"&&n!==null&&"name"in n&&n.name==="ton_addr"&&"address"in n&&typeof n.address=="string"}e(Rn,"isTonAddressItemReply");var W;function K(n){W=n}e(K,"setEnvironments");function q(){let n=W?.tonConnectManifestUrl;if(!n)throw new Error("OKX TON requires a TonConnect manifest URL. Please provide it through the provider environments.");return n}e(q,"getTonConnectManifestUrl");var j=0;function y(){return j+=1,j.toString()}e(y,"nextTonRequestId");async function S(n){if(!A(n))return B.formatAccountsToCAIP([]);let o=n.payload.items.find(Rn);if(!o)return B.formatAccountsToCAIP([]);let{Address:t}=await _n(async()=>await import("@ton/core")),r=t.parseRaw(o.address).toString({bounceable:!1,urlSafe:!0});return B.formatAccountsToCAIP([r])}e(S,"connectEventToCAIP");function Mn(n){let o=n.error.code===x?k.REJECTED_BY_USER:k.SEND_TX_ERROR;return new P(o,n.error.message,n.error)}e(Mn,"toSignerError");var O=class{static{e(this,"OKXTonSigner")}provider;constructor(o){this.provider=o}async signMessage(){throw P.UnimplementedError("signMessage")}async signAndSendTx(o){let{validUntil:t,network:r,from:s,messages:f}=o,{Address:i,Cell:u}=await Bn(async()=>await import("@ton/core")),g={valid_until:t,network:r??kn.MAINNET,...s&&{from:i.parse(s).toRawString()},messages:f.map(({stateInit:m,payload:R,...Pn})=>({...Pn,...m!=null&&{stateInit:m},...R!=null&&{payload:R}}))};try{let m=await this.provider.send({method:"sendTransaction",params:[JSON.stringify(g)],id:y()});if("error"in m)throw Mn(m);return{hash:u.fromBase64(m.result).hash().toString("hex")}}catch(m){throw m instanceof P?m:new P(k.SEND_TX_ERROR,void 0,m)}}};import{Networks as Ln}from"@rango-dev/wallets-shared";import{SignerError as Dn}from"rango-types";var I=class{static{e(this,"OKXUTXOSigner")}provider;constructor(o){this.provider=o}async signMessage(){throw Dn.UnimplementedError("signMessage")}async signAndSendTx(o){let{asset:t,psbt:r}=o;if(!r)throw new Error("No PSBT found to sign. Ensure a valid PSBT is provided.");if(t.blockchain!==Ln.BTC)throw new Error(`Signing ${t.blockchain} transaction is not implemented by the signer.`);let s=Buffer.from(r.unsignedPsbtBase64,"base64").toString("hex"),f=r.inputsToSign.flatMap(({address:i,signingIndexes:u})=>u.map(g=>({index:g,address:i})));try{let i=await this.provider.signPsbt(s,{autoFinalized:!0,toSignInputs:f});return{hash:await this.provider.pushPsbt(i)}}catch(i){throw new Error(i?.message||"Error during signing transaction")}}};async function M(n){let o=E(n,Un),t=E(n,Xn),r=E(n,jn),s=E(n,Wn),f=E(n,Kn),i=new qn,{DefaultEvmSigner:u}=await V(async()=>await import("@rango-dev/signer-evm")),{DefaultTronSigner:g}=await V(async()=>await import("@rango-dev/signer-tron"));return i.registerSigner(T.EVM,new u(o)),i.registerSigner(T.SOLANA,new b(t)),i.registerSigner(T.TRANSFER,new I(r)),i.registerSigner(T.TON,new O(s)),i.registerSigner(T.TRON,new g(f)),i}e(M,"getSigners");import{EVM_NAMESPACE as F,SOLANA_NAMESPACE as H,UTXO_NAMESPACE as z,TON_NAMESPACE as G,TRON_NAMESPACE as J}from"@hub3js/namespaces";function d(){let{okxwallet:n,okxTonWallet:o}=window;if(!n&&!o)return null;let t=new Map;return n&&t.set(F,n),n.solana&&t.set(H,n.solana),n.bitcoin&&t.set(z,n.bitcoin),o?.tonconnect&&t.set(G,o.tonconnect),n.tronLink&&t.set(J,n.tronLink),t}e(d,"okx");function Y(){let n=d();if(!n)throw new Error("OKX Wallet is not injected. Please check your wallet.");return n}e(Y,"getInstanceOrThrow");function p(){let o=d()?.get(F);if(!o)throw new Error("OKX Wallet not injected or EVM not enabled. Please check your wallet.");return o}e(p,"evmOKX");function h(){let o=d()?.get(H);if(!o)throw new Error("OKX Wallet not injected or Solana not enabled. Please check your wallet.");return o}e(h,"solanaOKX");function w(){let o=d()?.get(z);if(!o)throw new Error("OKX Wallet not injected or Utxo not enabled. Please check your wallet.");return o}e(w,"bitcoinOKX");function l(){let o=d()?.get(G);if(!o)throw new Error("OKX Wallet not injected or TON not enabled. Please check your wallet.");return o}e(l,"tonOKX");function v(){let o=d()?.get(J);if(!o)throw new Error("OKX Wallet not injected or Tron not enabled. Please check your wallet.");return o}e(v,"tronOKX");async function $(){let o=await w().connect();if(o.error?.message)throw new Error(o.error.message);return o}e($,"getBitcoinAccounts");function L(n){if(typeof n!="object"||n===null)return!1;let o=n;return typeof o.message=="object"&&o.message!==null&&typeof o.message.action=="string"}e(L,"isOkxTronMessageEvent");var a="okx",Q=2,x=300,Z=200,nn=4001,Gn=[c.ETHEREUM,c.BSC,c.POLYGON,c.FANTOM,c.ARBITRUM,c.OPTIMISM,c.CRONOS,c.BOBA,c.GNOSIS,c.MOONBEAM,c.MOONRIVER,c.HARMONY,c.AVAX_CCHAIN],on={name:"OKX",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/okx/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",brave:"https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",firefox:"https://addons.mozilla.org/en-US/firefox/addon/okexwallet",homepage:"https://www.okx.com/web3"},properties:[{name:"namespaces",value:{selection:"multiple",data:[{label:"EVM",value:"EVM",id:"ETH",getSupportedChains:n=>n.filter(o=>Gn.includes(o.name))},{label:"Solana",value:"Solana",id:"SOLANA",getSupportedChains:n=>Fn(n)},{label:"BTC",value:"UTXO",id:"BTC",getSupportedChains:n=>n.filter(o=>o.name===Vn.BTC)},{label:"Ton",value:"Ton",id:"TON",getSupportedChains:n=>Hn(n)},{label:"Tron",value:"Tron",id:"TRON",getSupportedChains:n=>zn(n)}]}},{name:"signers",value:{getSigners:async()=>M(Y())}}]};import{NamespaceBuilder as Jn}from"@hub3js/core";import{actions as N,builders as C,utils as Yn}from"@hub3js/evm";import*as tn from"@hub3js/std/builders";import{standardizeAndThrowError as $n}from"@hub3js/std/operators";var[Qn,en]=C.changeAccountSubscriber(p).onSwitchAccount(n=>{n.payload.length||n.preventDefault()}).format(async(n,o)=>{let t=await n.request({method:"eth_chainId"});return Yn.formatAccountsToCAIP(o.filter(Boolean),t)}).build(),Zn=C.connect().action(N.connect(p)).before(Qn).or(en).or($n).build(),no=tn.disconnect().before(()=>{p().disconnect()}).after(en).build(),oo=C.canSwitchNetwork().action(N.canSwitchNetwork()).build(),to=C.canEagerConnect().action(N.canEagerConnect(p)).build(),eo=C.getChainId().action(N.getChainId(p)).build(),rn=new Jn("EVM",a).action(Zn).action(no).action(to).action(oo).action(eo).build();import{ActionBuilder as ro,NamespaceBuilder as io}from"@hub3js/core";import{actions as cn,builders as sn,utils as co}from"@hub3js/solana";import*as an from"@hub3js/std/builders";import{standardizeAndThrowError as so}from"@hub3js/std/operators";var[ao,mn]=sn.changeAccountSubscriber(h).onSwitchAccount(n=>{n.payload||n.preventDefault()}).format(async(n,o)=>co.formatAccountsToCAIP(o?[o]:[])).build(),mo=sn.connect().action(cn.connect(h)).before(ao).or(mn).or(so).build(),uo=an.disconnect().before(()=>{h().disconnect()}).after(mn).build(),po=new ro("canEagerConnect").action(cn.canEagerConnect(h)).build(),dn=new io("Solana",a).action(mo).action(uo).action(po).build();import{NamespaceBuilder as ho}from"@hub3js/core";import*as pn from"@hub3js/std/builders";import{standardizeAndThrowError as wo}from"@hub3js/std/operators";import{builders as ln}from"@rango-dev/wallets-core/namespaces/ton";import"@rango-dev/wallets-core/namespaces/ton";function lo(n){return async()=>{let o=n(),t;try{t=await o.restoreConnection()}catch{}if((!t||!A(t))&&(t=await o.connect(Q,{manifestUrl:q(),items:[{name:"ton_addr"}]})),!A(t))throw t.payload.code===x?new Error("User rejected the request."):new Error(`Couldn't connect to OKX TON. code: ${t.payload.code}, message: ${t.payload.message}`);let r=await S(t);if(!r.length)throw new Error("Couldn't find any TON address!");return r}}e(lo,"connect");function fo(n){return async()=>{try{let o=await n().restoreConnection();return A(o)}catch{return!1}}}e(fo,"canEagerConnect");function go(n){return async()=>{try{await n().send({method:"disconnect",params:[],id:y()})}catch{}}}e(go,"disconnect");var _={connect:lo,canEagerConnect:fo,disconnect:go};import{ChangeAccountSubscriberBuilder as un}from"@hub3js/std/hooks";import{utils as Ao}from"@rango-dev/wallets-core/namespaces/ton";var Eo=e(n=>new un().getInstance(n).format(async o=>{try{let t=await o.restoreConnection();return await S(t)}catch{return Ao.formatAccountsToCAIP([])}}).addEventListener((o,t)=>{o.on("accountChanged",t)}).removeEventListener((o,t)=>{o.off("accountChanged",t)}),"changeAccountSubscriber"),To=e(n=>new un().getInstance(n).onSwitchAccount((o,t)=>{o.preventDefault(),t.action("disconnect")}).format(async()=>[]).addEventListener((o,t)=>{o.on("disconnect",t)}).removeEventListener((o,t)=>{o.off("disconnect",t)}),"disconnectSubscriber"),D={changeAccountSubscriber:Eo,disconnectSubscriber:To};var[vo,fn]=D.changeAccountSubscriber(l).build(),[Co,gn]=D.disconnectSubscriber(l).build(),bo=ln.connect().action(_.connect(l)).before(vo).before(Co).or(gn).or(fn).or(wo).build(),yo=pn.disconnect().before(_.disconnect(l)).after(fn).after(gn).build(),So=ln.canEagerConnect().action(_.canEagerConnect(l)).build(),An=new ho("Ton",a).action(bo).action(yo).action(So).build();import{NamespaceBuilder as Ro}from"@hub3js/core";import*as Tn from"@hub3js/std/builders";import{standardizeAndThrowError as Bo}from"@hub3js/std/operators";import"@rango-dev/wallets-core/namespaces/tron";import{builders as hn}from"@rango-dev/wallets-core/namespaces/tron";import{utils as Po}from"@rango-dev/wallets-core/namespaces/tron";var Oo=e(async()=>{let n=v(),o=await n.request({method:"tron_requestAccounts"});if(o?.code&&o.code!==Z)throw o.code===nn?new Error("User rejected the request."):new Error(o.message??"Failed to connect to OKX Wallet Tron.");return Po.formatAccountsToCAIP([n.tronWeb.defaultAddress.base58])},"connect"),xo=e(async()=>{try{return!!v().ready}catch{return!1}},"canEagerConnect"),U={connect:Oo,canEagerConnect:xo};import{ChangeAccountSubscriberBuilder as Io}from"@hub3js/std/hooks";import{utils as No}from"@rango-dev/wallets-core/namespaces/tron";var _o=e(n=>new Io().getInstance(n).onSwitchAccount((o,t)=>{let r=o.payload?.data;if(!L(r)){o.preventDefault();return}let{action:s}=r.message;if(s==="disconnect"){o.preventDefault(),t.action("disconnect");return}(s!=="accountsChanged"||typeof r.message.data?.address!="string")&&o.preventDefault()}).format(async(o,t)=>{let r=t.data,s=L(r)&&r.message.action==="accountsChanged"?r.message.data?.address:void 0;if(typeof s!="string")throw new Error("No Tron address received from OKX Wallet.");return No.formatAccountsToCAIP([s])}).addEventListener((o,t)=>{window.addEventListener("message",t)}).removeEventListener((o,t)=>{window.removeEventListener("message",t)}),"changeAccountSubscriber"),En={changeAccountSubscriber:_o};var[ko,wn]=En.changeAccountSubscriber(v).build(),Mo=hn.connect().action(U.connect).before(ko).or(wn).or(Bo).build(),Lo=hn.canEagerConnect().action(U.canEagerConnect).build(),Do=Tn.disconnect().after(wn).build(),vn=new Ro("Tron",a).action(Mo).action(Do).action(Lo).build();import{NamespaceBuilder as Vo}from"@hub3js/core";import*as Cn from"@hub3js/std/builders";import{standardizeAndThrowError as Fo}from"@hub3js/std/operators";import{CAIP_BITCOIN_CHAIN_ID as Ho,utils as zo}from"@rango-dev/wallets-core/namespaces/utxo";import{builders as Go}from"@rango-dev/wallets-core/namespaces/utxo";import{ActionBuilder as Uo}from"@hub3js/core";import{ChangeAccountSubscriberBuilder as Xo}from"@hub3js/std/hooks";import{CAIP_BITCOIN_CHAIN_ID as jo,utils as Wo}from"@rango-dev/wallets-core/namespaces/utxo";var Ko=e(n=>new Xo().getInstance(n).onSwitchAccount(o=>{o.payload?.address||o.preventDefault()}).format(async(o,t)=>Wo.formatAccountsToCAIP(t?[t.address]:[],jo)).addEventListener((o,t)=>o.addListener("accountChanged",t)).removeEventListener((o,t)=>o.removeListener("accountChanged",t)),"changeAccountSubscriber");function qo(n){return new Uo("canEagerConnect").action(async()=>{let o=n();try{return!!(await o.getAccounts()).length}catch{return!1}})}e(qo,"canEagerConnect");var X={changeAccountSubscriber:Ko,canEagerConnect:qo};var[Jo,bn]=X.changeAccountSubscriber(w).build(),Yo=X.canEagerConnect(w).build(),$o=Go.connect().action(async function(){let n=await $();if(!n?.address)throw new Error("Couldn't find any address!");return zo.formatAccountsToCAIP([n.address],Ho)}).before(Jo).or(bn).or(Fo).build(),Qo=Cn.disconnect().before(()=>{w().disconnect()}).after(bn).build(),yn=new Vo("UTXO",a).action($o).action(Qo).action(Yo).build();var Sn=e(()=>new Zo(a).init(function(n,o){K(o);let[,t]=n.state();d()&&(t("installed",!0),console.debug("[okx] instance detected.",n))}).config("metadata",on).add("solana",dn).add("evm",rn).add("utxo",yn).add("ton",An).add("tron",vn).build(),"buildProvider");var rr=e(()=>nt().version("1.0.0",Sn()).build(),"versions");export{rr as versions};
|
|
1
|
+
var Dn=Object.defineProperty;var e=(n,o)=>Dn(n,"name",{value:o,configurable:!0});import{defineVersions as wt}from"@hub3js/core/utils";import{ProviderBuilder as bt}from"@hub3js/core";import{LegacyNetworks as a}from"@rango-dev/wallets-core/legacy";import{Networks as no}from"@rango-dev/wallets-shared";import{solanaBlockchain as oo,tonBlockchain as to,TransactionType as eo,tronBlockchain as ro}from"rango-types";import{EVM_NAMESPACE as Gn,SOLANA_NAMESPACE as Jn,UTXO_NAMESPACE as Yn,TON_NAMESPACE as $n,TRON_NAMESPACE as Qn}from"@hub3js/namespaces";import{dynamicImportWithRefinedError as D,getNetworkInstance as v}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as Zn,TransactionType as A}from"rango-types";import{DefaultSolanaSigner as Un}from"@rango-dev/signer-solana";import{SignerError as Wn,SignerErrorCode as jn}from"rango-types";var y=class extends Un{static{e(this,"OKXSolanaSigner")}constructor(o){super(o)}async signMessage(o){try{let{signature:t}=await this.provider.request({method:"signMessage",params:{message:o}});return t}catch(t){throw new Wn(jn.SIGN_TX_ERROR,void 0,t)}}};import{dynamicImportWithRefinedError as Hn}from"@rango-dev/wallets-shared";import{SignerError as x,SignerErrorCode as M,TonChainID as qn}from"rango-types";import{utils as R}from"@hub3js/tvm";import{dynamicImportWithRefinedError as Xn}from"@rango-dev/wallets-shared";function T(n){return!!n&&n.event==="connect"&&Array.isArray(n.payload?.items)}e(T,"isTonConnectEventSuccess");function Kn(n){return typeof n=="object"&&n!==null&&"name"in n&&n.name==="ton_addr"&&"address"in n&&typeof n.address=="string"}e(Kn,"isTonAddressItemReply");var H;function q(n){H=n}e(q,"setEnvironments");function V(){let n=H?.tonConnectManifestUrl;if(!n)throw new Error("OKX TON requires a TonConnect manifest URL. Please provide it through the provider environments.");return n}e(V,"getTonConnectManifestUrl");var K=0;function P(){return K+=1,K.toString()}e(P,"nextTonRequestId");async function O(n){if(!T(n))return R.formatAccountsToCAIP([]);let o=n.payload.items.find(Kn);if(!o)return R.formatAccountsToCAIP([]);let{Address:t}=await Xn(async()=>await import("@ton/core")),r=t.parseRaw(o.address).toString({bounceable:!1,urlSafe:!0});return R.formatAccountsToCAIP([r])}e(O,"connectEventToCAIP");function Vn(n){let o=n.error.code===N?M.REJECTED_BY_USER:M.SEND_TX_ERROR;return new x(o,n.error.message,n.error)}e(Vn,"toSignerError");var I=class{static{e(this,"OKXTonSigner")}provider;constructor(o){this.provider=o}async signMessage(){throw x.UnimplementedError("signMessage")}async signAndSendTx(o){let{validUntil:t,network:r,from:m,messages:g}=o,{Address:i,Cell:p}=await Hn(async()=>await import("@ton/core")),E={valid_until:t,network:r??qn.MAINNET,...m&&{from:i.parse(m).toRawString()},messages:g.map(({stateInit:s,payload:h,...Ln})=>({...Ln,...s!=null&&{stateInit:s},...h!=null&&{payload:h}}))};try{let s=await this.provider.send({method:"sendTransaction",params:[JSON.stringify(E)],id:P()});if("error"in s)throw Vn(s);return{hash:p.fromBase64(s.result).hash().toString("hex")}}catch(s){throw s instanceof x?s:new x(M.SEND_TX_ERROR,void 0,s)}}};import{Networks as Fn}from"@rango-dev/wallets-shared";import{SignerError as zn}from"rango-types";var _=class{static{e(this,"OKXUTXOSigner")}provider;constructor(o){this.provider=o}async signMessage(){throw zn.UnimplementedError("signMessage")}async signAndSendTx(o){let{asset:t,psbt:r}=o;if(!r)throw new Error("No PSBT found to sign. Ensure a valid PSBT is provided.");if(t.blockchain!==Fn.BTC)throw new Error(`Signing ${t.blockchain} transaction is not implemented by the signer.`);let m=Buffer.from(r.unsignedPsbtBase64,"base64").toString("hex"),g=r.inputsToSign.flatMap(({address:i,signingIndexes:p})=>p.map(E=>({index:E,address:i})));try{let i=await this.provider.signPsbt(m,{autoFinalized:!0,toSignInputs:g});return{hash:await this.provider.pushPsbt(i)}}catch(i){throw new Error(i?.message||"Error during signing transaction")}}};import{EVM_NAMESPACE as F,SOLANA_NAMESPACE as z,TON_NAMESPACE as G,TRON_NAMESPACE as J,UTXO_NAMESPACE as Y}from"@hub3js/namespaces";import{getInstanceOrThrow as $}from"@hub3js/sui";function d(){let{okxwallet:n,okxTonWallet:o}=window;if(!n&&!o)return null;let t=new Map;return n&&t.set(F,n),n.solana&&t.set(z,n.solana),n.bitcoin&&t.set(Y,n.bitcoin),o?.tonconnect&&t.set(G,o.tonconnect),n.tronLink&&t.set(J,n.tronLink),t}e(d,"okx");function Q(){let n=d();if(!n)throw new Error("OKX Wallet is not injected. Please check your wallet.");return n}e(Q,"getInstanceOrThrow");function l(){let o=d()?.get(F);if(!o)throw new Error("OKX Wallet not injected or EVM not enabled. Please check your wallet.");return o}e(l,"evmOKX");function b(){let o=d()?.get(z);if(!o)throw new Error("OKX Wallet not injected or Solana not enabled. Please check your wallet.");return o}e(b,"solanaOKX");function w(){let o=d()?.get(Y);if(!o)throw new Error("OKX Wallet not injected or Utxo not enabled. Please check your wallet.");return o}e(w,"bitcoinOKX");function f(){let o=d()?.get(G);if(!o)throw new Error("OKX Wallet not injected or TON not enabled. Please check your wallet.");return o}e(f,"tonOKX");function S(){let o=d()?.get(J);if(!o)throw new Error("OKX Wallet not injected or Tron not enabled. Please check your wallet.");return o}e(S,"tronOKX");function Z(){try{return $(u)}catch{return null}}e(Z,"suiWalletInstance");function nn(){return $(u)}e(nn,"suiWalletInstanceOrThrow");async function on(){let o=await w().connect();if(o.error?.message)throw new Error(o.error.message);return o}e(on,"getBitcoinAccounts");function L(n){if(typeof n!="object"||n===null)return!1;let o=n;return typeof o.message=="object"&&o.message!==null&&typeof o.message.action=="string"}e(L,"isOkxTronMessageEvent");async function U(n){let o=v(n,Gn),t=v(n,Jn),r=v(n,Yn),m=v(n,$n),g=v(n,Qn),i=new Zn,{DefaultEvmSigner:p}=await D(async()=>await import("@rango-dev/signer-evm")),{DefaultTronSigner:E}=await D(async()=>await import("@rango-dev/signer-tron"));i.registerSigner(A.EVM,new p(o)),i.registerSigner(A.SOLANA,new y(t)),i.registerSigner(A.TRANSFER,new _(r)),i.registerSigner(A.TON,new I(m)),i.registerSigner(A.TRON,new E(g));let s=Z();if(s){let{DefaultSuiSigner:h}=await D(async()=>await import("@rango-dev/signer-sui"));i.registerSigner(A.SUI,new h(s))}return i}e(U,"getSigners");var c="okx",tn=2,N=300,en=200,rn=4001,u="OKX Wallet",io=[a.ETHEREUM,a.BSC,a.POLYGON,a.FANTOM,a.ARBITRUM,a.OPTIMISM,a.CRONOS,a.BOBA,a.GNOSIS,a.MOONBEAM,a.MOONRIVER,a.HARMONY,a.AVAX_CCHAIN],cn={name:"OKX",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/okx/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",brave:"https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",firefox:"https://addons.mozilla.org/en-US/firefox/addon/okexwallet",homepage:"https://www.okx.com/web3"},properties:[{name:"namespaces",value:{selection:"multiple",data:[{label:"EVM",value:"EVM",id:"ETH",getSupportedChains:n=>n.filter(o=>io.includes(o.name))},{label:"Solana",value:"Solana",id:"SOLANA",getSupportedChains:n=>oo(n)},{label:"BTC",value:"UTXO",id:"BTC",getSupportedChains:n=>n.filter(o=>o.name===no.BTC)},{label:"Ton",value:"Ton",id:"TON",getSupportedChains:n=>to(n)},{label:"Tron",value:"Tron",id:"TRON",getSupportedChains:n=>ro(n)},{label:"Sui",value:"Sui",id:"SUI",getSupportedChains:n=>n.filter(o=>o.type===eo.SUI)}]}},{name:"signers",value:{getSigners:async()=>U(Q())}}]};import{NamespaceBuilder as co}from"@hub3js/core";import{actions as B,builders as C,utils as so}from"@hub3js/evm";import*as sn from"@hub3js/std/builders";import{standardizeAndThrowError as ao}from"@hub3js/std/operators";var[mo,an]=C.changeAccountSubscriber(l).onSwitchAccount(n=>{n.payload.length||n.preventDefault()}).format(async(n,o)=>{let t=await n.request({method:"eth_chainId"});return so.formatAccountsToCAIP(o.filter(Boolean),t)}).build(),uo=C.connect().action(B.connect(l)).before(mo).or(an).or(ao).build(),po=sn.disconnect().before(()=>{l().disconnect()}).after(an).build(),lo=C.canSwitchNetwork().action(B.canSwitchNetwork()).build(),fo=C.canEagerConnect().action(B.canEagerConnect(l)).build(),Ao=C.getChainId().action(B.getChainId(l)).build(),mn=new co("EVM",c).action(uo).action(po).action(fo).action(lo).action(Ao).build();import{ActionBuilder as go,NamespaceBuilder as Eo}from"@hub3js/core";import{actions as dn,builders as un,utils as ho}from"@hub3js/solana";import*as pn from"@hub3js/std/builders";import{standardizeAndThrowError as To}from"@hub3js/std/operators";var[bo,ln]=un.changeAccountSubscriber(b).onSwitchAccount(n=>{n.payload||n.preventDefault()}).format(async(n,o)=>ho.formatAccountsToCAIP(o?[o]:[])).build(),wo=un.connect().action(dn.connect(b)).before(bo).or(ln).or(To).build(),So=pn.disconnect().before(()=>{b().disconnect()}).after(ln).build(),vo=new go("canEagerConnect").action(dn.canEagerConnect(b)).build(),fn=new Eo("Solana",c).action(wo).action(So).action(vo).build();import{NamespaceBuilder as No}from"@hub3js/core";import*as gn from"@hub3js/std/builders";import{standardizeAndThrowError as _o}from"@hub3js/std/operators";import{builders as En}from"@hub3js/tvm";import"@hub3js/tvm";function Co(n){return async()=>{let o=n(),t;try{t=await o.restoreConnection()}catch{}if((!t||!T(t))&&(t=await o.connect(tn,{manifestUrl:V(),items:[{name:"ton_addr"}]})),!T(t))throw t.payload.code===N?new Error("User rejected the request."):new Error(`Couldn't connect to OKX TON. code: ${t.payload.code}, message: ${t.payload.message}`);let r=await O(t);if(!r.length)throw new Error("Couldn't find any TON address!");return r}}e(Co,"connect");function yo(n){return async()=>{try{let o=await n().restoreConnection();return T(o)}catch{return!1}}}e(yo,"canEagerConnect");function Po(n){return async()=>{try{await n().send({method:"disconnect",params:[],id:P()})}catch{}}}e(Po,"disconnect");var k={connect:Co,canEagerConnect:yo,disconnect:Po};import{ChangeAccountSubscriberBuilder as An}from"@hub3js/std/hooks";import{utils as Oo}from"@hub3js/tvm";var xo=e(n=>new An().getInstance(n).format(async o=>{try{let t=await o.restoreConnection();return await O(t)}catch{return Oo.formatAccountsToCAIP([])}}).addEventListener((o,t)=>{o.on("accountChanged",t)}).removeEventListener((o,t)=>{o.off("accountChanged",t)}),"changeAccountSubscriber"),Io=e(n=>new An().getInstance(n).onSwitchAccount((o,t)=>{o.preventDefault(),t.action("disconnect")}).format(async()=>[]).addEventListener((o,t)=>{o.on("disconnect",t)}).removeEventListener((o,t)=>{o.off("disconnect",t)}),"disconnectSubscriber"),W={changeAccountSubscriber:xo,disconnectSubscriber:Io};var[Bo,hn]=W.changeAccountSubscriber(f).build(),[ko,Tn]=W.disconnectSubscriber(f).build(),Ro=En.connect().action(k.connect(f)).before(Bo).before(ko).or(Tn).or(hn).or(_o).build(),Mo=gn.disconnect().before(k.disconnect(f)).after(hn).after(Tn).build(),Lo=En.canEagerConnect().action(k.canEagerConnect(f)).build(),bn=new No("Ton",c).action(Ro).action(Mo).action(Lo).build();import{NamespaceBuilder as Ho}from"@hub3js/core";import*as Sn from"@hub3js/std/builders";import{standardizeAndThrowError as qo}from"@hub3js/std/operators";import"@rango-dev/wallets-core/namespaces/tron";import{builders as vn}from"@rango-dev/wallets-core/namespaces/tron";import{utils as Do}from"@rango-dev/wallets-core/namespaces/tron";var Uo=e(async()=>{let n=S(),o=await n.request({method:"tron_requestAccounts"});if(o?.code&&o.code!==en)throw o.code===rn?new Error("User rejected the request."):new Error(o.message??"Failed to connect to OKX Wallet Tron.");return Do.formatAccountsToCAIP([n.tronWeb.defaultAddress.base58])},"connect"),Wo=e(async()=>{try{return!!S().ready}catch{return!1}},"canEagerConnect"),j={connect:Uo,canEagerConnect:Wo};import{ChangeAccountSubscriberBuilder as jo}from"@hub3js/std/hooks";import{utils as Xo}from"@rango-dev/wallets-core/namespaces/tron";var Ko=e(n=>new jo().getInstance(n).onSwitchAccount((o,t)=>{let r=o.payload?.data;if(!L(r)){o.preventDefault();return}let{action:m}=r.message;if(m==="disconnect"){o.preventDefault(),t.action("disconnect");return}(m!=="accountsChanged"||typeof r.message.data?.address!="string")&&o.preventDefault()}).format(async(o,t)=>{let r=t.data,m=L(r)&&r.message.action==="accountsChanged"?r.message.data?.address:void 0;if(typeof m!="string")throw new Error("No Tron address received from OKX Wallet.");return Xo.formatAccountsToCAIP([m])}).addEventListener((o,t)=>{window.addEventListener("message",t)}).removeEventListener((o,t)=>{window.removeEventListener("message",t)}),"changeAccountSubscriber"),wn={changeAccountSubscriber:Ko};var[Vo,Cn]=wn.changeAccountSubscriber(S).build(),Fo=vn.connect().action(j.connect).before(Vo).or(Cn).or(qo).build(),zo=vn.canEagerConnect().action(j.canEagerConnect).build(),Go=Sn.disconnect().after(Cn).build(),yn=new Ho("Tron",c).action(Fo).action(Go).action(zo).build();import{NamespaceBuilder as Yo}from"@hub3js/core";import*as On from"@hub3js/std/builders";import{standardizeAndThrowError as $o}from"@hub3js/std/operators";import{actions as Qo,builders as xn,hooks as Zo}from"@hub3js/sui";function Jo(n){let o;return[t=>{let r=n();if(!r)throw new Error("Trying to subscribe to your Sui wallet, but seems its instance is not available.");o=r.features["standard:events"].on("disconnect",()=>{t.action("disconnect")})},(t,r)=>(typeof o=="function"&&o(),r)]}e(Jo,"disconnectSubscriber");var Pn={disconnectSubscriber:Jo};var[nt,In]=Zo.changeAccountSubscriber({name:u}),[ot,Nn]=Pn.disconnectSubscriber(nn),tt=xn.canEagerConnect().action(Qo.canEagerConnect({name:u})).build(),et=xn.connect({name:u}).before(nt).before(ot).or(In).or(Nn).or($o).build(),rt=On.disconnect().after(In).after(Nn).build(),_n=new Yo("Sui",c).action(et).action(rt).action(tt).build();import{NamespaceBuilder as ut}from"@hub3js/core";import*as Bn from"@hub3js/std/builders";import{standardizeAndThrowError as pt}from"@hub3js/std/operators";import{CAIP_BITCOIN_CHAIN_ID as lt,utils as ft}from"@rango-dev/wallets-core/namespaces/utxo";import{builders as At}from"@rango-dev/wallets-core/namespaces/utxo";import{ActionBuilder as it}from"@hub3js/core";import{ChangeAccountSubscriberBuilder as ct}from"@hub3js/std/hooks";import{CAIP_BITCOIN_CHAIN_ID as st,utils as at}from"@rango-dev/wallets-core/namespaces/utxo";var mt=e(n=>new ct().getInstance(n).onSwitchAccount(o=>{o.payload?.address||o.preventDefault()}).format(async(o,t)=>at.formatAccountsToCAIP(t?[t.address]:[],st)).addEventListener((o,t)=>o.addListener("accountChanged",t)).removeEventListener((o,t)=>o.removeListener("accountChanged",t)),"changeAccountSubscriber");function dt(n){return new it("canEagerConnect").action(async()=>{let o=n();try{return!!(await o.getAccounts()).length}catch{return!1}})}e(dt,"canEagerConnect");var X={changeAccountSubscriber:mt,canEagerConnect:dt};var[gt,kn]=X.changeAccountSubscriber(w).build(),Et=X.canEagerConnect(w).build(),ht=At.connect().action(async function(){let n=await on();if(!n?.address)throw new Error("Couldn't find any address!");return ft.formatAccountsToCAIP([n.address],lt)}).before(gt).or(kn).or(pt).build(),Tt=Bn.disconnect().before(()=>{w().disconnect()}).after(kn).build(),Rn=new ut("UTXO",c).action(ht).action(Tt).action(Et).build();var Mn=e(()=>new bt(c).init(function(n,o){q(o);let[,t]=n.state();d()&&(t("installed",!0),console.debug("[okx] instance detected.",n))}).config("metadata",cn).add("solana",fn).add("evm",mn).add("utxo",Rn).add("ton",bn).add("tron",yn).add("sui",_n).build(),"buildProvider");var Ur=e(()=>wt().version("1.0.0",Mn()).build(),"versions");export{Ur as versions};
|
|
2
2
|
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/mod.ts", "../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/signers/solana.ts", "../src/signers/ton.ts", "../src/namespaces/ton/utils.ts", "../src/signers/utxo.ts", "../src/utils.ts", "../src/namespaces/evm.ts", "../src/namespaces/solana.ts", "../src/namespaces/ton/ton.ts", "../src/actions/ton.ts", "../src/builders/ton.ts", "../src/namespaces/tron.ts", "../src/actions/tron.ts", "../src/builders/tron.ts", "../src/namespaces/utxo.ts", "../src/builders/utxo.ts"],
|
|
4
|
-
"sourcesContent": ["import { defineVersions } from '@hub3js/core/utils';\n\nimport { buildProvider } from './provider.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\n", "import type { Environments } from './namespaces/ton/types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { solana } from './namespaces/solana.js';\nimport { ton } from './namespaces/ton/ton.js';\nimport { setEnvironments } from './namespaces/ton/utils.js';\nimport { tron } from './namespaces/tron.js';\nimport { utxo } from './namespaces/utxo.js';\nimport { okx as okxInstance } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments?: Environments) {\n setEnvironments(environments);\n const [, setState] = context.state();\n\n if (okxInstance()) {\n setState('installed', true);\n console.debug('[okx] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('solana', solana)\n .add('evm', evm)\n .add('utxo', utxo)\n .add('ton', ton)\n .add('tron', tron)\n\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\nimport { Networks } from '@rango-dev/wallets-shared';\nimport {\n type BlockchainMeta,\n solanaBlockchain,\n tonBlockchain,\n type TransferBlockchainMeta,\n tronBlockchain,\n} from 'rango-types';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'okx';\nexport const TON_CONNECT_PROTOCOL_VERSION = 2;\nexport const TON_CONNECT_USER_REJECTED_CODE = 300;\nexport const TRON_OK_REQUEST_CODE = 200;\n// EIP-1193 user-rejected-request code returned by `tron_requestAccounts`.\nexport const TRON_USER_REJECTION_CODE = 4001;\n\nexport const OKX_WALLET_SUPPORTED_CHAINS = [\n LegacyNetworks.ETHEREUM,\n LegacyNetworks.BSC,\n LegacyNetworks.POLYGON,\n LegacyNetworks.FANTOM,\n LegacyNetworks.ARBITRUM,\n LegacyNetworks.OPTIMISM,\n LegacyNetworks.CRONOS,\n LegacyNetworks.BOBA,\n LegacyNetworks.GNOSIS,\n LegacyNetworks.MOONBEAM,\n LegacyNetworks.MOONRIVER,\n LegacyNetworks.HARMONY,\n LegacyNetworks.AVAX_CCHAIN,\n];\n\nexport const metadata: ProviderMetadata = {\n name: 'OKX',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/okx/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',\n brave:\n 'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',\n firefox: 'https://addons.mozilla.org/en-US/firefox/addon/okexwallet',\n homepage: 'https://www.okx.com/web3',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'multiple',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter((blockchainMeta) =>\n OKX_WALLET_SUPPORTED_CHAINS.includes(\n blockchainMeta.name as LegacyNetworks\n )\n ),\n },\n {\n label: 'Solana',\n value: 'Solana',\n id: 'SOLANA',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n solanaBlockchain(allBlockchains),\n },\n {\n label: 'BTC',\n value: 'UTXO',\n id: 'BTC',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter(\n (chain): chain is TransferBlockchainMeta =>\n chain.name === Networks.BTC\n ),\n },\n {\n label: 'Ton',\n value: 'Ton',\n id: 'TON',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n tonBlockchain(allBlockchains),\n },\n {\n label: 'Tron',\n value: 'Tron',\n id: 'TRON',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n tronBlockchain(allBlockchains),\n },\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners(getInstanceOrThrow()) },\n },\n ],\n};\n", "import type { Provider } from './types.js';\nimport type { SignerFactory } from 'rango-types';\n\nimport {\n EVM_NAMESPACE,\n SOLANA_NAMESPACE,\n UTXO_NAMESPACE,\n TON_NAMESPACE,\n TRON_NAMESPACE,\n} from '@hub3js/namespaces';\nimport {\n dynamicImportWithRefinedError,\n getNetworkInstance,\n} from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nimport { OKXSolanaSigner } from './signers/solana.js';\nimport { OKXTonSigner } from './signers/ton.js';\nimport { OKXUTXOSigner } from './signers/utxo.js';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = getNetworkInstance(provider, EVM_NAMESPACE);\n const solProvider = getNetworkInstance(provider, SOLANA_NAMESPACE);\n const utxoProvider = getNetworkInstance(provider, UTXO_NAMESPACE);\n const tonProvider = getNetworkInstance(provider, TON_NAMESPACE);\n const tronProvider = getNetworkInstance(provider, TRON_NAMESPACE);\n\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-evm')\n );\n const { DefaultTronSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-tron')\n );\n signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));\n signers.registerSigner(TxType.SOLANA, new OKXSolanaSigner(solProvider));\n signers.registerSigner(TxType.TRANSFER, new OKXUTXOSigner(utxoProvider));\n signers.registerSigner(TxType.TON, new OKXTonSigner(tonProvider));\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(tronProvider));\n\n return signers;\n}\n", "import {\n DefaultSolanaSigner,\n type SolanaExternalProvider,\n} from '@rango-dev/signer-solana';\nimport { SignerError, SignerErrorCode } from 'rango-types';\n\nexport class OKXSolanaSigner extends DefaultSolanaSigner {\n constructor(provider: SolanaExternalProvider) {\n super(provider);\n }\n\n async signMessage(msg: string): Promise<string> {\n try {\n const { signature } = await this.provider.request({\n method: 'signMessage',\n params: {\n message: msg,\n },\n });\n return signature;\n } catch (error) {\n throw new SignerError(SignerErrorCode.SIGN_TX_ERROR, undefined, error);\n }\n }\n}\n", "import type {\n TonConnectWalletResponseError,\n TonProviderApi,\n} from '../namespaces/ton/types.js';\nimport type { GenericSigner, TonTransaction } from 'rango-types';\n\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\nimport { SignerError, SignerErrorCode, TonChainID } from 'rango-types';\n\nimport { TON_CONNECT_USER_REJECTED_CODE } from '../constants.js';\nimport { nextTonRequestId } from '../namespaces/ton/utils.js';\n\nfunction toSignerError(response: TonConnectWalletResponseError): SignerError {\n const code =\n response.error.code === TON_CONNECT_USER_REJECTED_CODE\n ? SignerErrorCode.REJECTED_BY_USER\n : SignerErrorCode.SEND_TX_ERROR;\n return new SignerError(code, response.error.message, response.error);\n}\n\nexport class OKXTonSigner implements GenericSigner<TonTransaction> {\n private provider: TonProviderApi;\n\n constructor(provider: TonProviderApi) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: TonTransaction): Promise<{ hash: string }> {\n const { validUntil, network, from, messages } = tx;\n\n const { Address, Cell } = await dynamicImportWithRefinedError(\n async () => await import('@ton/core')\n );\n\n const transactionPayload = {\n valid_until: validUntil,\n network: network ?? TonChainID.MAINNET,\n ...(from && { from: Address.parse(from).toRawString() }),\n messages: messages.map(({ stateInit, payload, ...message }) => ({\n ...message,\n ...(stateInit != null && { stateInit }),\n ...(payload != null && { payload }),\n })),\n };\n\n try {\n const response = await this.provider.send({\n method: 'sendTransaction',\n params: [JSON.stringify(transactionPayload)],\n id: nextTonRequestId(),\n });\n\n if ('error' in response) {\n throw toSignerError(response);\n }\n\n const hash = Cell.fromBase64(response.result).hash().toString('hex');\n return { hash };\n } catch (error) {\n if (error instanceof SignerError) {\n throw error;\n }\n throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);\n }\n }\n}\n", "import type {\n Environments,\n TonAddressItemReply,\n TonConnectEvent,\n TonConnectEventSuccess,\n} from './types.js';\nimport type { CaipAccount } from '@rango-dev/wallets-core/namespaces/common';\n\nimport { utils as tonCoreUtils } from '@rango-dev/wallets-core/namespaces/ton';\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\n\nexport function isTonConnectEventSuccess(\n event: TonConnectEvent\n): event is TonConnectEventSuccess {\n return (\n !!event && event.event === 'connect' && Array.isArray(event.payload?.items)\n );\n}\n\nexport function isTonAddressItemReply(\n item: unknown\n): item is TonAddressItemReply {\n return (\n typeof item === 'object' &&\n item !== null &&\n 'name' in item &&\n item.name === 'ton_addr' &&\n 'address' in item &&\n typeof item.address === 'string'\n );\n}\n\nlet environments: Environments | undefined;\n\nexport function setEnvironments(env?: Environments) {\n environments = env;\n}\n\nexport function getTonConnectManifestUrl(): string {\n const manifestUrl = environments?.tonConnectManifestUrl;\n if (!manifestUrl) {\n throw new Error(\n 'OKX TON requires a TonConnect manifest URL. Please provide it through the provider environments.'\n );\n }\n return manifestUrl;\n}\n\nlet tonRequestId = 0;\n\n// TonConnect requires a unique string `id` on every request sent to the bridge.\nexport function nextTonRequestId(): string {\n tonRequestId += 1;\n return tonRequestId.toString();\n}\n\n// Convert a `ConnectEvent`'s raw `<workchain>:<hex>` address to user-friendly CAIP.\nexport async function connectEventToCAIP(\n connectEvent: TonConnectEvent\n): Promise<CaipAccount[]> {\n if (!isTonConnectEventSuccess(connectEvent)) {\n return tonCoreUtils.formatAccountsToCAIP([]);\n }\n\n const addressItem = connectEvent.payload.items.find(isTonAddressItemReply);\n if (!addressItem) {\n return tonCoreUtils.formatAccountsToCAIP([]);\n }\n\n const { Address } = await dynamicImportWithRefinedError(\n async () => await import('@ton/core')\n );\n const userFriendlyAddress = Address.parseRaw(addressItem.address).toString({\n bounceable: false,\n urlSafe: true,\n });\n\n return tonCoreUtils.formatAccountsToCAIP([userFriendlyAddress]);\n}\n", "import type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/utxo';\nimport type { GenericSigner, Transfer } from 'rango-types';\n\nimport { Networks } from '@rango-dev/wallets-shared';\nimport { SignerError } from 'rango-types';\n\nexport class OKXUTXOSigner implements GenericSigner<Transfer> {\n private provider: ProviderAPI;\n constructor(provider: ProviderAPI) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: Transfer): Promise<{ hash: string }> {\n const { asset, psbt } = tx;\n if (!psbt) {\n throw new Error(\n 'No PSBT found to sign. Ensure a valid PSBT is provided.'\n );\n }\n\n if (asset.blockchain !== Networks.BTC) {\n throw new Error(\n `Signing ${asset.blockchain} transaction is not implemented by the signer.`\n );\n }\n // 1. Decode Base64 to hex\n const psbtHex = Buffer.from(psbt.unsignedPsbtBase64, 'base64').toString(\n 'hex'\n );\n\n // 2. Build UniSat inputs\n const toSignInputs = psbt.inputsToSign.flatMap(\n ({ address, signingIndexes }) =>\n signingIndexes.map((index) => ({ index, address }))\n );\n\n try {\n // 3. Sign (& auto-finalize)\n const signedPsbtHex = await this.provider.signPsbt(psbtHex, {\n autoFinalized: true,\n toSignInputs,\n });\n\n // 4. Push signed psbt\n const transactionHash = await this.provider.pushPsbt(signedPsbtHex);\n\n return { hash: transactionHash };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n throw new Error(error?.message || 'Error during signing transaction');\n }\n }\n}\n", "import type { TonProviderApi } from './namespaces/ton/types.js';\nimport type { OkxBtcAddress, OkxTronMessageEvent, Provider } from './types.js';\nimport type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';\nimport type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';\nimport type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';\nimport type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport {\n EVM_NAMESPACE,\n SOLANA_NAMESPACE,\n UTXO_NAMESPACE,\n TON_NAMESPACE,\n TRON_NAMESPACE,\n} from '@hub3js/namespaces';\n\nexport function okx(): Provider | null {\n const { okxwallet, okxTonWallet } = window;\n if (!okxwallet && !okxTonWallet) {\n return null;\n }\n const instances: Provider = new Map();\n if (okxwallet) {\n instances.set(EVM_NAMESPACE, okxwallet);\n }\n if (okxwallet.solana) {\n instances.set(SOLANA_NAMESPACE, okxwallet.solana);\n }\n if (okxwallet.bitcoin) {\n instances.set(UTXO_NAMESPACE, okxwallet.bitcoin);\n }\n if (okxTonWallet?.tonconnect) {\n instances.set(TON_NAMESPACE, okxTonWallet.tonconnect);\n }\n if (okxwallet.tronLink) {\n instances.set(TRON_NAMESPACE, okxwallet.tronLink);\n }\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = okx();\n\n if (!instances) {\n throw new Error('OKX Wallet is not injected. Please check your wallet.');\n }\n\n return instances;\n}\n\nexport function evmOKX(): EvmProviderApi {\n const instances = okx();\n\n const evmInstance = instances?.get(EVM_NAMESPACE);\n\n if (!evmInstance) {\n throw new Error(\n 'OKX Wallet not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance as EvmProviderApi;\n}\n\nexport function solanaOKX(): SolanaProviderApi {\n const instance = okx();\n const solanaInstance = instance?.get(SOLANA_NAMESPACE);\n\n if (!solanaInstance) {\n throw new Error(\n 'OKX Wallet not injected or Solana not enabled. Please check your wallet.'\n );\n }\n\n return solanaInstance;\n}\nexport function bitcoinOKX(): UtxoProviderApi {\n const instance = okx();\n const bitcoinInstance = instance?.get(UTXO_NAMESPACE);\n\n if (!bitcoinInstance) {\n throw new Error(\n 'OKX Wallet not injected or Utxo not enabled. Please check your wallet.'\n );\n }\n\n return bitcoinInstance;\n}\n\nexport function tonOKX(): TonProviderApi {\n const instance = okx();\n const tonInstance = instance?.get(TON_NAMESPACE);\n\n if (!tonInstance) {\n throw new Error(\n 'OKX Wallet not injected or TON not enabled. Please check your wallet.'\n );\n }\n\n return tonInstance as TonProviderApi;\n}\n\nexport function tronOKX(): TronProviderApi {\n const instance = okx();\n const tronInstance = instance?.get(TRON_NAMESPACE);\n\n if (!tronInstance) {\n throw new Error(\n 'OKX Wallet not injected or Tron not enabled. Please check your wallet.'\n );\n }\n\n return tronInstance;\n}\nexport async function getBitcoinAccounts(): Promise<OkxBtcAddress> {\n const instance = bitcoinOKX();\n const requestResult = await instance.connect();\n\n if (requestResult.error?.message) {\n throw new Error(requestResult.error.message);\n }\n\n return requestResult;\n}\n\nexport function isOkxTronMessageEvent(\n value: unknown\n): value is OkxTronMessageEvent {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const event = value as { message?: { action?: unknown } };\n return (\n typeof event.message === 'object' &&\n event.message !== null &&\n typeof event.message.action === 'string'\n );\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = builders\n .changeAccountSubscriber(evmOKX)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload.length) {\n event.preventDefault();\n }\n })\n .format(async (instance, event) => {\n const chainId = await instance.request({ method: 'eth_chainId' });\n // The wallet may emit a `null` value in its `sent` event.\n return utils.formatAccountsToCAIP(event.filter(Boolean), chainId);\n })\n .build();\nconst connect = builders\n .connect()\n .action(actions.connect(evmOKX))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .before(() => {\n evmOKX().disconnect();\n })\n .after(changeAccountCleanup)\n .build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n .action(actions.canSwitchNetwork())\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(actions.canEagerConnect(evmOKX))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmOKX))\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .action(canSwitchNetwork)\n .action(getChainId)\n .build();\n\nexport { evm };\n", "import type { SolanaActions } from '@hub3js/solana';\n\nimport { ActionBuilder, NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/solana';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { solanaOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = builders\n .changeAccountSubscriber(solanaOKX)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload) {\n event.preventDefault();\n }\n })\n .format(async (_, event) => {\n // The wallet may emit a `null` value in its `sent` event.\n return utils.formatAccountsToCAIP(event ? [event] : []);\n })\n .build();\n\nconst connect = builders\n .connect()\n .action(actions.connect(solanaOKX))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<SolanaActions>()\n .before(() => {\n solanaOKX().disconnect();\n })\n .after(changeAccountCleanup)\n .build();\n\nconst canEagerConnect = new ActionBuilder<SolanaActions, 'canEagerConnect'>(\n 'canEagerConnect'\n)\n .action(actions.canEagerConnect(solanaOKX))\n .build();\n\nconst solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { solana };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport {\n builders,\n type TonActions,\n} from '@rango-dev/wallets-core/namespaces/ton';\n\nimport { tonActions } from '../../actions/ton.js';\nimport { tonBuilders } from '../../builders/ton.js';\nimport { WALLET_ID } from '../../constants.js';\nimport { tonOKX } from '../../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tonBuilders\n .changeAccountSubscriber(tonOKX)\n .build();\n\nconst [walletDisconnectSubscriber, walletDisconnectCleanup] = tonBuilders\n .disconnectSubscriber(tonOKX)\n .build();\n\nconst connect = builders\n .connect()\n .action(tonActions.connect(tonOKX))\n .before(changeAccountSubscriber)\n .before(walletDisconnectSubscriber)\n .or(walletDisconnectCleanup)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TonActions>()\n .before(tonActions.disconnect(tonOKX))\n .after(changeAccountCleanup)\n .after(walletDisconnectCleanup)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tonActions.canEagerConnect(tonOKX))\n .build();\n\nconst ton = new NamespaceBuilder<TonActions>('Ton', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { ton };\n", "import type {\n TonConnectEvent,\n TonProviderApi,\n} from '../namespaces/ton/types.js';\nimport type { Context, FunctionWithContext } from '@hub3js/core';\n\nimport { type TonActions } from '@rango-dev/wallets-core/namespaces/ton';\n\nimport {\n TON_CONNECT_PROTOCOL_VERSION,\n TON_CONNECT_USER_REJECTED_CODE,\n} from '../constants.js';\nimport {\n connectEventToCAIP,\n getTonConnectManifestUrl,\n isTonConnectEventSuccess,\n nextTonRequestId,\n} from '../namespaces/ton/utils.js';\n\nexport function connect(\n getInstance: () => TonProviderApi\n): FunctionWithContext<TonActions['connect'], Context> {\n return async () => {\n const instance = getInstance();\n\n /*\n * If the dApp was approved before, `restoreConnection` resolves the current\n * session without prompting the user; otherwise fall back to a fresh\n * connect request.\n */\n let connectEvent: TonConnectEvent | undefined;\n try {\n connectEvent = await instance.restoreConnection();\n } catch {\n // No restorable session; a fresh connect request is made below.\n }\n\n if (!connectEvent || !isTonConnectEventSuccess(connectEvent)) {\n connectEvent = await instance.connect(TON_CONNECT_PROTOCOL_VERSION, {\n manifestUrl: getTonConnectManifestUrl(),\n items: [{ name: 'ton_addr' }],\n });\n }\n\n if (!isTonConnectEventSuccess(connectEvent)) {\n // The bridge reports a user-cancelled prompt as a `connect_error` event.\n if (connectEvent.payload.code === TON_CONNECT_USER_REJECTED_CODE) {\n throw new Error('User rejected the request.');\n }\n throw new Error(\n `Couldn't connect to OKX TON. code: ${connectEvent.payload.code}, message: ${connectEvent.payload.message}`\n );\n }\n\n const accounts = await connectEventToCAIP(connectEvent);\n if (!accounts.length) {\n throw new Error(\"Couldn't find any TON address!\");\n }\n\n return accounts;\n };\n}\n\nexport function canEagerConnect(\n getInstance: () => TonProviderApi\n): FunctionWithContext<TonActions['canEagerConnect'], Context> {\n return async () => {\n /*\n * Auto connect may run this before the wallet is injected; it should never\n * throw.\n */\n try {\n const connectEvent = await getInstance().restoreConnection();\n return isTonConnectEventSuccess(connectEvent);\n } catch {\n return false;\n }\n };\n}\n\nexport function disconnect(getInstance: () => TonProviderApi) {\n return async () => {\n /*\n * Revoking the session on the wallet side is best effort; local state\n * cleanup should proceed even if it fails.\n */\n try {\n await getInstance().send({\n method: 'disconnect',\n params: [],\n id: nextTonRequestId(),\n });\n } catch {\n // ignore\n }\n };\n}\n\nexport const tonActions = { connect, canEagerConnect, disconnect };\n", "import type { TonProviderApi } from '../namespaces/ton/types.js';\n\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport { type TonActions, utils } from '@rango-dev/wallets-core/namespaces/ton';\n\nimport { connectEventToCAIP } from '../namespaces/ton/utils.js';\n\n/*\n * OKX emits its non-standard `accountChanged` event without a documented\n * payload, so the switched address can't be read from the event. Because the\n * bridge is standard TON Connect, `format` re-reads the active account from the\n * instance via `restoreConnection` instead\n */\nexport const changeAccountSubscriber = (getInstance: () => TonProviderApi) =>\n new ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>()\n .getInstance(getInstance)\n .format(async (instance) => {\n try {\n const connectEvent = await instance.restoreConnection();\n return await connectEventToCAIP(connectEvent);\n } catch {\n // No active session after the switch \u2014 treat as disconnected.\n return utils.formatAccountsToCAIP([]);\n }\n })\n .addEventListener((instance, callback) => {\n instance.on('accountChanged', callback);\n })\n .removeEventListener((instance, callback) => {\n instance.off('accountChanged', callback);\n });\n\nexport const disconnectSubscriber = (getInstance: () => TonProviderApi) =>\n new ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n event.preventDefault();\n void context.action('disconnect');\n })\n .format(async () => [])\n .addEventListener((instance, callback) => {\n instance.on('disconnect', callback);\n })\n .removeEventListener((instance, callback) => {\n instance.off('disconnect', callback);\n });\n\nexport const tonBuilders = { changeAccountSubscriber, disconnectSubscriber };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { type TronActions } from '@rango-dev/wallets-core/namespaces/tron';\nimport { builders } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport { tronActions } from '../actions/tron.js';\nimport { tronBuilders } from '../builders/tron.js';\nimport { WALLET_ID } from '../constants.js';\nimport { tronOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tronBuilders\n .changeAccountSubscriber(tronOKX)\n .build();\n\nconst connect = builders\n .connect()\n .action(tronActions.connect)\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tronActions.canEagerConnect)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TronActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst tron = new NamespaceBuilder<TronActions>('Tron', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { tron };\n", "import { utils } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport {\n TRON_OK_REQUEST_CODE,\n TRON_USER_REJECTION_CODE,\n} from '../constants.js';\nimport { tronOKX } from '../utils.js';\n\nconst connect = async () => {\n const instance = tronOKX();\n const accountsResult = await instance.request({\n method: 'tron_requestAccounts',\n });\n\n if (accountsResult?.code && accountsResult.code !== TRON_OK_REQUEST_CODE) {\n if (accountsResult.code === TRON_USER_REJECTION_CODE) {\n throw new Error('User rejected the request.');\n }\n throw new Error(\n accountsResult.message ?? 'Failed to connect to OKX Wallet Tron.'\n );\n }\n return utils.formatAccountsToCAIP([instance.tronWeb.defaultAddress.base58]);\n};\n\n/*\n * Wrapped in a try-catch in the case of wallet injection delay\n */\nconst canEagerConnect = async () => {\n try {\n const tronInstance = tronOKX();\n return !!tronInstance.ready;\n } catch {\n return false;\n }\n};\nexport const tronActions = { connect, canEagerConnect };\n", "import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n type ProviderAPI,\n type TronActions,\n utils,\n} from '@rango-dev/wallets-core/namespaces/tron';\n\nimport { isOkxTronMessageEvent } from '../utils.js';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<\n MessageEvent<unknown>,\n ProviderAPI,\n TronActions\n >()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n const data = event.payload?.data;\n\n if (!isOkxTronMessageEvent(data)) {\n event.preventDefault();\n return;\n }\n\n const { action } = data.message;\n\n if (action === 'disconnect') {\n event.preventDefault();\n context.action('disconnect');\n return;\n }\n\n /*\n * Change account only on `accountsChanged` with a string address (`format`\n * reads it). Everything else \u2014 including `accountsChanged` with address\n * `false` (its disconnect is handled above) \u2014 is ignored.\n */\n if (\n action !== 'accountsChanged' ||\n typeof data.message.data?.address !== 'string'\n ) {\n event.preventDefault();\n }\n })\n .format(async (_, event) => {\n const data = event.data;\n const address =\n isOkxTronMessageEvent(data) && data.message.action === 'accountsChanged'\n ? data.message.data?.address\n : undefined;\n if (typeof address !== 'string') {\n throw new Error('No Tron address received from OKX Wallet.');\n }\n return utils.formatAccountsToCAIP([address]);\n })\n .addEventListener((_, callback) => {\n window.addEventListener('message', callback);\n })\n .removeEventListener((_, callback) => {\n window.removeEventListener('message', callback);\n });\n\nexport const tronBuilders = { changeAccountSubscriber };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n utils,\n type UtxoActions,\n} from '@rango-dev/wallets-core/namespaces/utxo';\nimport { builders } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport { utxoBuilders } from '../builders/utxo.js';\nimport { WALLET_ID } from '../constants.js';\nimport { bitcoinOKX, getBitcoinAccounts } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = utxoBuilders\n .changeAccountSubscriber(bitcoinOKX)\n .build();\n\nconst canEagerConnect = utxoBuilders.canEagerConnect(bitcoinOKX).build();\n\nconst connect = builders\n .connect()\n .action(async function () {\n const accountsResult = await getBitcoinAccounts();\n\n if (!accountsResult?.address) {\n throw new Error(\"Couldn't find any address!\");\n }\n return utils.formatAccountsToCAIP(\n [accountsResult.address],\n CAIP_BITCOIN_CHAIN_ID\n );\n })\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<UtxoActions>()\n .before(() => {\n bitcoinOKX().disconnect();\n })\n .after(changeAccountCleanup)\n .build();\n\nconst utxo = new NamespaceBuilder<UtxoActions>('UTXO', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { utxo };\n", "import type { OkxBtcAddress } from '../types.js';\n\nimport { ActionBuilder } from '@hub3js/core';\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n type ProviderAPI,\n utils,\n type UtxoActions,\n} from '@rango-dev/wallets-core/namespaces/utxo';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<OkxBtcAddress, ProviderAPI, UtxoActions>()\n .getInstance(getInstance)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload?.address) {\n event.preventDefault();\n }\n })\n\n .format(async (_, event) => {\n return utils.formatAccountsToCAIP(\n event ? [event.address] : [],\n CAIP_BITCOIN_CHAIN_ID\n );\n })\n .addEventListener((instance, callback) => {\n return instance.addListener('accountChanged', callback);\n })\n .removeEventListener((instance, callback) => {\n return instance.removeListener('accountChanged', callback);\n });\n\nfunction canEagerConnect(getInstance: () => ProviderAPI) {\n return new ActionBuilder<UtxoActions, 'canEagerConnect'>(\n 'canEagerConnect'\n ).action(async () => {\n const instance = getInstance();\n try {\n const accounts = await instance.getAccounts();\n return !!accounts.length;\n } catch {\n return false;\n }\n });\n}\n\nexport const utxoBuilders = { changeAccountSubscriber, canEagerConnect };\n"],
|
|
5
|
-
"mappings": "iFAAA,OAAS,kBAAAA,OAAsB,qBCE/B,OAAS,mBAAAC,OAAuB,eCAhC,OAAS,kBAAAC,MAAsB,iCAC/B,OAAS,YAAAC,OAAgB,4BACzB,OAEE,oBAAAC,GACA,iBAAAC,G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,EAAQ,EAC3B,IAAI,SAAUC,EAAM,EACpB,IAAI,MAAOC,EAAG,EACd,IAAI,OAAQC,EAAI,EAChB,IAAI,MAAOC,EAAG,EACd,IAAI,OAAQC,EAAI,EAEhB,MAAM,EAlBW,iBDTtB,IAAMC,GAAWC,EAAA,IACfC,GAAe,EAAE,QAAQ,QAASC,GAAc,CAAC,EAAE,MAAM,EAD1C",
|
|
6
|
-
"names": ["defineVersions", "ProviderBuilder", "LegacyNetworks", "Networks", "solanaBlockchain", "tonBlockchain", "tronBlockchain", "EVM_NAMESPACE", "SOLANA_NAMESPACE", "UTXO_NAMESPACE", "TON_NAMESPACE", "TRON_NAMESPACE", "dynamicImportWithRefinedError", "getNetworkInstance", "DefaultSignerFactory", "TxType", "DefaultSolanaSigner", "SignerError", "SignerErrorCode", "OKXSolanaSigner", "DefaultSolanaSigner", "__name", "provider", "msg", "signature", "error", "SignerError", "SignerErrorCode", "dynamicImportWithRefinedError", "SignerError", "SignerErrorCode", "TonChainID", "tonCoreUtils", "dynamicImportWithRefinedError", "isTonConnectEventSuccess", "event", "__name", "isTonAddressItemReply", "item", "environments", "setEnvironments", "env", "getTonConnectManifestUrl", "manifestUrl", "tonRequestId", "nextTonRequestId", "connectEventToCAIP", "connectEvent", "tonCoreUtils", "addressItem", "Address", "dynamicImportWithRefinedError", "userFriendlyAddress", "toSignerError", "response", "code", "TON_CONNECT_USER_REJECTED_CODE", "SignerErrorCode", "SignerError", "__name", "OKXTonSigner", "provider", "tx", "validUntil", "network", "from", "messages", "Address", "Cell", "dynamicImportWithRefinedError", "transactionPayload", "TonChainID", "stateInit", "payload", "message", "nextTonRequestId", "error", "Networks", "SignerError", "OKXUTXOSigner", "__name", "provider", "SignerError", "tx", "asset", "psbt", "Networks", "psbtHex", "toSignInputs", "address", "signingIndexes", "index", "signedPsbtHex", "error", "
|
|
3
|
+
"sources": ["../src/mod.ts", "../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/signers/solana.ts", "../src/signers/ton.ts", "../src/namespaces/ton/utils.ts", "../src/signers/utxo.ts", "../src/utils.ts", "../src/namespaces/evm.ts", "../src/namespaces/solana.ts", "../src/namespaces/ton/ton.ts", "../src/actions/ton.ts", "../src/builders/ton.ts", "../src/namespaces/tron.ts", "../src/actions/tron.ts", "../src/builders/tron.ts", "../src/namespaces/sui.ts", "../src/hooks/sui.ts", "../src/namespaces/utxo.ts", "../src/builders/utxo.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineVersions } from '@hub3js/core/utils';\n\nimport { buildProvider } from './provider.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\n", "import type { Environments } from './namespaces/ton/types.js';\n\nimport { ProviderBuilder } from '@hub3js/core';\n\nimport { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { solana } from './namespaces/solana.js';\nimport { ton } from './namespaces/ton/ton.js';\nimport { setEnvironments } from './namespaces/ton/utils.js';\nimport { tron } from './namespaces/tron.js';\nimport { sui } from './namespaces/sui.js';\nimport { utxo } from './namespaces/utxo.js';\nimport { okx as okxInstance } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context, environments?: Environments) {\n setEnvironments(environments);\n const [, setState] = context.state();\n\n if (okxInstance()) {\n setState('installed', true);\n console.debug('[okx] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('solana', solana)\n .add('evm', evm)\n .add('utxo', utxo)\n .add('ton', ton)\n .add('tron', tron)\n .add('sui', sui)\n\n .build();\n\nexport { buildProvider };\n", "import type { ProviderMetadata } from '@hub3js/core';\n\nimport { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\nimport { Networks } from '@rango-dev/wallets-shared';\nimport {\n type BlockchainMeta,\n solanaBlockchain,\n tonBlockchain,\n type SuiBlockchainMeta,\n TransactionType,\n type TransferBlockchainMeta,\n tronBlockchain,\n} from 'rango-types';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'okx';\nexport const TON_CONNECT_PROTOCOL_VERSION = 2;\nexport const TON_CONNECT_USER_REJECTED_CODE = 300;\nexport const TRON_OK_REQUEST_CODE = 200;\n// EIP-1193 user-rejected-request code returned by `tron_requestAccounts`.\nexport const TRON_USER_REJECTION_CODE = 4001;\nexport const WALLET_NAME_IN_WALLET_STANDARD = 'OKX Wallet';\n\nexport const OKX_WALLET_SUPPORTED_CHAINS = [\n LegacyNetworks.ETHEREUM,\n LegacyNetworks.BSC,\n LegacyNetworks.POLYGON,\n LegacyNetworks.FANTOM,\n LegacyNetworks.ARBITRUM,\n LegacyNetworks.OPTIMISM,\n LegacyNetworks.CRONOS,\n LegacyNetworks.BOBA,\n LegacyNetworks.GNOSIS,\n LegacyNetworks.MOONBEAM,\n LegacyNetworks.MOONRIVER,\n LegacyNetworks.HARMONY,\n LegacyNetworks.AVAX_CCHAIN,\n];\n\nexport const metadata: ProviderMetadata = {\n name: 'OKX',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/okx/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',\n brave:\n 'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',\n firefox: 'https://addons.mozilla.org/en-US/firefox/addon/okexwallet',\n homepage: 'https://www.okx.com/web3',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'multiple',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter((blockchainMeta) =>\n OKX_WALLET_SUPPORTED_CHAINS.includes(\n blockchainMeta.name as LegacyNetworks\n )\n ),\n },\n {\n label: 'Solana',\n value: 'Solana',\n id: 'SOLANA',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n solanaBlockchain(allBlockchains),\n },\n {\n label: 'BTC',\n value: 'UTXO',\n id: 'BTC',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter(\n (chain): chain is TransferBlockchainMeta =>\n chain.name === Networks.BTC\n ),\n },\n {\n label: 'Ton',\n value: 'Ton',\n id: 'TON',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n tonBlockchain(allBlockchains),\n },\n {\n label: 'Tron',\n value: 'Tron',\n id: 'TRON',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n tronBlockchain(allBlockchains),\n },\n {\n label: 'Sui',\n value: 'Sui',\n id: 'SUI',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n allBlockchains.filter(\n (chain): chain is SuiBlockchainMeta =>\n chain.type === TransactionType.SUI\n ),\n },\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners(getInstanceOrThrow()) },\n },\n ],\n};\n", "import type { Provider } from './types.js';\nimport type { SignerFactory } from 'rango-types';\n\nimport {\n EVM_NAMESPACE,\n SOLANA_NAMESPACE,\n UTXO_NAMESPACE,\n TON_NAMESPACE,\n TRON_NAMESPACE,\n} from '@hub3js/namespaces';\nimport {\n dynamicImportWithRefinedError,\n getNetworkInstance,\n} from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nimport { OKXSolanaSigner } from './signers/solana.js';\nimport { OKXTonSigner } from './signers/ton.js';\nimport { OKXUTXOSigner } from './signers/utxo.js';\nimport { suiWalletInstance } from './utils.js';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = getNetworkInstance(provider, EVM_NAMESPACE);\n const solProvider = getNetworkInstance(provider, SOLANA_NAMESPACE);\n const utxoProvider = getNetworkInstance(provider, UTXO_NAMESPACE);\n const tonProvider = getNetworkInstance(provider, TON_NAMESPACE);\n const tronProvider = getNetworkInstance(provider, TRON_NAMESPACE);\n\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-evm')\n );\n const { DefaultTronSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-tron')\n );\n signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));\n signers.registerSigner(TxType.SOLANA, new OKXSolanaSigner(solProvider));\n signers.registerSigner(TxType.TRANSFER, new OKXUTXOSigner(utxoProvider));\n signers.registerSigner(TxType.TON, new OKXTonSigner(tonProvider));\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(tronProvider));\n\n const suiProvider = suiWalletInstance();\n if (suiProvider) {\n const { DefaultSuiSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-sui')\n );\n signers.registerSigner(TxType.SUI, new DefaultSuiSigner(suiProvider));\n }\n\n return signers;\n}\n", "import {\n DefaultSolanaSigner,\n type SolanaExternalProvider,\n} from '@rango-dev/signer-solana';\nimport { SignerError, SignerErrorCode } from 'rango-types';\n\nexport class OKXSolanaSigner extends DefaultSolanaSigner {\n constructor(provider: SolanaExternalProvider) {\n super(provider);\n }\n\n async signMessage(msg: string): Promise<string> {\n try {\n const { signature } = await this.provider.request({\n method: 'signMessage',\n params: {\n message: msg,\n },\n });\n return signature;\n } catch (error) {\n throw new SignerError(SignerErrorCode.SIGN_TX_ERROR, undefined, error);\n }\n }\n}\n", "import type {\n TonConnectWalletResponseError,\n TonProviderApi,\n} from '../namespaces/ton/types.js';\nimport type { GenericSigner, TonTransaction } from 'rango-types';\n\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\nimport { SignerError, SignerErrorCode, TonChainID } from 'rango-types';\n\nimport { TON_CONNECT_USER_REJECTED_CODE } from '../constants.js';\nimport { nextTonRequestId } from '../namespaces/ton/utils.js';\n\nfunction toSignerError(response: TonConnectWalletResponseError): SignerError {\n const code =\n response.error.code === TON_CONNECT_USER_REJECTED_CODE\n ? SignerErrorCode.REJECTED_BY_USER\n : SignerErrorCode.SEND_TX_ERROR;\n return new SignerError(code, response.error.message, response.error);\n}\n\nexport class OKXTonSigner implements GenericSigner<TonTransaction> {\n private provider: TonProviderApi;\n\n constructor(provider: TonProviderApi) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: TonTransaction): Promise<{ hash: string }> {\n const { validUntil, network, from, messages } = tx;\n\n const { Address, Cell } = await dynamicImportWithRefinedError(\n async () => await import('@ton/core')\n );\n\n const transactionPayload = {\n valid_until: validUntil,\n network: network ?? TonChainID.MAINNET,\n ...(from && { from: Address.parse(from).toRawString() }),\n messages: messages.map(({ stateInit, payload, ...message }) => ({\n ...message,\n ...(stateInit != null && { stateInit }),\n ...(payload != null && { payload }),\n })),\n };\n\n try {\n const response = await this.provider.send({\n method: 'sendTransaction',\n params: [JSON.stringify(transactionPayload)],\n id: nextTonRequestId(),\n });\n\n if ('error' in response) {\n throw toSignerError(response);\n }\n\n const hash = Cell.fromBase64(response.result).hash().toString('hex');\n return { hash };\n } catch (error) {\n if (error instanceof SignerError) {\n throw error;\n }\n throw new SignerError(SignerErrorCode.SEND_TX_ERROR, undefined, error);\n }\n }\n}\n", "import type {\n Environments,\n TonAddressItemReply,\n TonConnectEvent,\n TonConnectEventSuccess,\n} from './types.js';\nimport type { CaipAccount } from '@hub3js/std/types';\n\nimport { utils as tonCoreUtils } from '@hub3js/tvm';\nimport { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';\n\nexport function isTonConnectEventSuccess(\n event: TonConnectEvent\n): event is TonConnectEventSuccess {\n return (\n !!event && event.event === 'connect' && Array.isArray(event.payload?.items)\n );\n}\n\nexport function isTonAddressItemReply(\n item: unknown\n): item is TonAddressItemReply {\n return (\n typeof item === 'object' &&\n item !== null &&\n 'name' in item &&\n item.name === 'ton_addr' &&\n 'address' in item &&\n typeof item.address === 'string'\n );\n}\n\nlet environments: Environments | undefined;\n\nexport function setEnvironments(env?: Environments) {\n environments = env;\n}\n\nexport function getTonConnectManifestUrl(): string {\n const manifestUrl = environments?.tonConnectManifestUrl;\n if (!manifestUrl) {\n throw new Error(\n 'OKX TON requires a TonConnect manifest URL. Please provide it through the provider environments.'\n );\n }\n return manifestUrl;\n}\n\nlet tonRequestId = 0;\n\n// TonConnect requires a unique string `id` on every request sent to the bridge.\nexport function nextTonRequestId(): string {\n tonRequestId += 1;\n return tonRequestId.toString();\n}\n\n// Convert a `ConnectEvent`'s raw `<workchain>:<hex>` address to user-friendly CAIP.\nexport async function connectEventToCAIP(\n connectEvent: TonConnectEvent\n): Promise<CaipAccount[]> {\n if (!isTonConnectEventSuccess(connectEvent)) {\n return tonCoreUtils.formatAccountsToCAIP([]);\n }\n\n const addressItem = connectEvent.payload.items.find(isTonAddressItemReply);\n if (!addressItem) {\n return tonCoreUtils.formatAccountsToCAIP([]);\n }\n\n const { Address } = await dynamicImportWithRefinedError(\n async () => await import('@ton/core')\n );\n const userFriendlyAddress = Address.parseRaw(addressItem.address).toString({\n bounceable: false,\n urlSafe: true,\n });\n\n return tonCoreUtils.formatAccountsToCAIP([userFriendlyAddress]);\n}\n", "import type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/utxo';\nimport type { GenericSigner, Transfer } from 'rango-types';\n\nimport { Networks } from '@rango-dev/wallets-shared';\nimport { SignerError } from 'rango-types';\n\nexport class OKXUTXOSigner implements GenericSigner<Transfer> {\n private provider: ProviderAPI;\n constructor(provider: ProviderAPI) {\n this.provider = provider;\n }\n\n async signMessage(): Promise<string> {\n throw SignerError.UnimplementedError('signMessage');\n }\n\n async signAndSendTx(tx: Transfer): Promise<{ hash: string }> {\n const { asset, psbt } = tx;\n if (!psbt) {\n throw new Error(\n 'No PSBT found to sign. Ensure a valid PSBT is provided.'\n );\n }\n\n if (asset.blockchain !== Networks.BTC) {\n throw new Error(\n `Signing ${asset.blockchain} transaction is not implemented by the signer.`\n );\n }\n // 1. Decode Base64 to hex\n const psbtHex = Buffer.from(psbt.unsignedPsbtBase64, 'base64').toString(\n 'hex'\n );\n\n // 2. Build UniSat inputs\n const toSignInputs = psbt.inputsToSign.flatMap(\n ({ address, signingIndexes }) =>\n signingIndexes.map((index) => ({ index, address }))\n );\n\n try {\n // 3. Sign (& auto-finalize)\n const signedPsbtHex = await this.provider.signPsbt(psbtHex, {\n autoFinalized: true,\n toSignInputs,\n });\n\n // 4. Push signed psbt\n const transactionHash = await this.provider.pushPsbt(signedPsbtHex);\n\n return { hash: transactionHash };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n throw new Error(error?.message || 'Error during signing transaction');\n }\n }\n}\n", "import type { TonProviderApi } from './namespaces/ton/types.js';\nimport type { OkxBtcAddress, OkxTronMessageEvent, Provider } from './types.js';\nimport type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';\nimport type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';\nimport type { ProviderAPI as SuiProviderApi } from '@hub3js/sui';\nimport type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';\nimport type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport {\n EVM_NAMESPACE,\n SOLANA_NAMESPACE,\n TON_NAMESPACE,\n TRON_NAMESPACE,\n UTXO_NAMESPACE,\n} from '@hub3js/namespaces';\nimport { getInstanceOrThrow as getSuiInstanceOrThrow } from '@hub3js/sui';\n\nimport { WALLET_NAME_IN_WALLET_STANDARD } from './constants.js';\n\nexport function okx(): Provider | null {\n const { okxwallet, okxTonWallet } = window;\n if (!okxwallet && !okxTonWallet) {\n return null;\n }\n const instances: Provider = new Map();\n if (okxwallet) {\n instances.set(EVM_NAMESPACE, okxwallet);\n }\n if (okxwallet.solana) {\n instances.set(SOLANA_NAMESPACE, okxwallet.solana);\n }\n if (okxwallet.bitcoin) {\n instances.set(UTXO_NAMESPACE, okxwallet.bitcoin);\n }\n if (okxTonWallet?.tonconnect) {\n instances.set(TON_NAMESPACE, okxTonWallet.tonconnect);\n }\n if (okxwallet.tronLink) {\n instances.set(TRON_NAMESPACE, okxwallet.tronLink);\n }\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = okx();\n\n if (!instances) {\n throw new Error('OKX Wallet is not injected. Please check your wallet.');\n }\n\n return instances;\n}\n\nexport function evmOKX(): EvmProviderApi {\n const instances = okx();\n\n const evmInstance = instances?.get(EVM_NAMESPACE);\n\n if (!evmInstance) {\n throw new Error(\n 'OKX Wallet not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance as EvmProviderApi;\n}\n\nexport function solanaOKX(): SolanaProviderApi {\n const instance = okx();\n const solanaInstance = instance?.get(SOLANA_NAMESPACE);\n\n if (!solanaInstance) {\n throw new Error(\n 'OKX Wallet not injected or Solana not enabled. Please check your wallet.'\n );\n }\n\n return solanaInstance;\n}\nexport function bitcoinOKX(): UtxoProviderApi {\n const instance = okx();\n const bitcoinInstance = instance?.get(UTXO_NAMESPACE);\n\n if (!bitcoinInstance) {\n throw new Error(\n 'OKX Wallet not injected or Utxo not enabled. Please check your wallet.'\n );\n }\n\n return bitcoinInstance;\n}\n\nexport function tonOKX(): TonProviderApi {\n const instance = okx();\n const tonInstance = instance?.get(TON_NAMESPACE);\n\n if (!tonInstance) {\n throw new Error(\n 'OKX Wallet not injected or TON not enabled. Please check your wallet.'\n );\n }\n\n return tonInstance as TonProviderApi;\n}\n\nexport function tronOKX(): TronProviderApi {\n const instance = okx();\n const tronInstance = instance?.get(TRON_NAMESPACE);\n\n if (!tronInstance) {\n throw new Error(\n 'OKX Wallet not injected or Tron not enabled. Please check your wallet.'\n );\n }\n\n return tronInstance;\n}\n\nexport function suiWalletInstance(): SuiProviderApi | null {\n try {\n return getSuiInstanceOrThrow(WALLET_NAME_IN_WALLET_STANDARD);\n } catch {\n return null;\n }\n}\n\nexport function suiWalletInstanceOrThrow(): SuiProviderApi {\n return getSuiInstanceOrThrow(WALLET_NAME_IN_WALLET_STANDARD);\n}\nexport async function getBitcoinAccounts(): Promise<OkxBtcAddress> {\n const instance = bitcoinOKX();\n const requestResult = await instance.connect();\n\n if (requestResult.error?.message) {\n throw new Error(requestResult.error.message);\n }\n\n return requestResult;\n}\n\nexport function isOkxTronMessageEvent(\n value: unknown\n): value is OkxTronMessageEvent {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const event = value as { message?: { action?: unknown } };\n return (\n typeof event.message === 'object' &&\n event.message !== null &&\n typeof event.message.action === 'string'\n );\n}\n", "import type { EvmActions } from '@hub3js/evm';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/evm';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = builders\n .changeAccountSubscriber(evmOKX)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload.length) {\n event.preventDefault();\n }\n })\n .format(async (instance, event) => {\n const chainId = await instance.request({ method: 'eth_chainId' });\n // The wallet may emit a `null` value in its `sent` event.\n return utils.formatAccountsToCAIP(event.filter(Boolean), chainId);\n })\n .build();\nconst connect = builders\n .connect()\n .action(actions.connect(evmOKX))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .before(() => {\n evmOKX().disconnect();\n })\n .after(changeAccountCleanup)\n .build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n .action(actions.canSwitchNetwork())\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(actions.canEagerConnect(evmOKX))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmOKX))\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .action(canSwitchNetwork)\n .action(getChainId)\n .build();\n\nexport { evm };\n", "import type { SolanaActions } from '@hub3js/solana';\n\nimport { ActionBuilder, NamespaceBuilder } from '@hub3js/core';\nimport { actions, builders, utils } from '@hub3js/solana';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\n\nimport { WALLET_ID } from '../constants.js';\nimport { solanaOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = builders\n .changeAccountSubscriber(solanaOKX)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload) {\n event.preventDefault();\n }\n })\n .format(async (_, event) => {\n // The wallet may emit a `null` value in its `sent` event.\n return utils.formatAccountsToCAIP(event ? [event] : []);\n })\n .build();\n\nconst connect = builders\n .connect()\n .action(actions.connect(solanaOKX))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<SolanaActions>()\n .before(() => {\n solanaOKX().disconnect();\n })\n .after(changeAccountCleanup)\n .build();\n\nconst canEagerConnect = new ActionBuilder<SolanaActions, 'canEagerConnect'>(\n 'canEagerConnect'\n)\n .action(actions.canEagerConnect(solanaOKX))\n .build();\n\nconst solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { solana };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { builders, type TonActions } from '@hub3js/tvm';\n\nimport { tonActions } from '../../actions/ton.js';\nimport { tonBuilders } from '../../builders/ton.js';\nimport { WALLET_ID } from '../../constants.js';\nimport { tonOKX } from '../../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tonBuilders\n .changeAccountSubscriber(tonOKX)\n .build();\n\nconst [walletDisconnectSubscriber, walletDisconnectCleanup] = tonBuilders\n .disconnectSubscriber(tonOKX)\n .build();\n\nconst connect = builders\n .connect()\n .action(tonActions.connect(tonOKX))\n .before(changeAccountSubscriber)\n .before(walletDisconnectSubscriber)\n .or(walletDisconnectCleanup)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TonActions>()\n .before(tonActions.disconnect(tonOKX))\n .after(changeAccountCleanup)\n .after(walletDisconnectCleanup)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tonActions.canEagerConnect(tonOKX))\n .build();\n\nconst ton = new NamespaceBuilder<TonActions>('Ton', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { ton };\n", "import type {\n TonConnectEvent,\n TonProviderApi,\n} from '../namespaces/ton/types.js';\nimport type { Context, FunctionWithContext } from '@hub3js/core';\n\nimport { type TonActions } from '@hub3js/tvm';\n\nimport {\n TON_CONNECT_PROTOCOL_VERSION,\n TON_CONNECT_USER_REJECTED_CODE,\n} from '../constants.js';\nimport {\n connectEventToCAIP,\n getTonConnectManifestUrl,\n isTonConnectEventSuccess,\n nextTonRequestId,\n} from '../namespaces/ton/utils.js';\n\nexport function connect(\n getInstance: () => TonProviderApi\n): FunctionWithContext<TonActions['connect'], Context> {\n return async () => {\n const instance = getInstance();\n\n /*\n * If the dApp was approved before, `restoreConnection` resolves the current\n * session without prompting the user; otherwise fall back to a fresh\n * connect request.\n */\n let connectEvent: TonConnectEvent | undefined;\n try {\n connectEvent = await instance.restoreConnection();\n } catch {\n // No restorable session; a fresh connect request is made below.\n }\n\n if (!connectEvent || !isTonConnectEventSuccess(connectEvent)) {\n connectEvent = await instance.connect(TON_CONNECT_PROTOCOL_VERSION, {\n manifestUrl: getTonConnectManifestUrl(),\n items: [{ name: 'ton_addr' }],\n });\n }\n\n if (!isTonConnectEventSuccess(connectEvent)) {\n // The bridge reports a user-cancelled prompt as a `connect_error` event.\n if (connectEvent.payload.code === TON_CONNECT_USER_REJECTED_CODE) {\n throw new Error('User rejected the request.');\n }\n throw new Error(\n `Couldn't connect to OKX TON. code: ${connectEvent.payload.code}, message: ${connectEvent.payload.message}`\n );\n }\n\n const accounts = await connectEventToCAIP(connectEvent);\n if (!accounts.length) {\n throw new Error(\"Couldn't find any TON address!\");\n }\n\n return accounts;\n };\n}\n\nexport function canEagerConnect(\n getInstance: () => TonProviderApi\n): FunctionWithContext<TonActions['canEagerConnect'], Context> {\n return async () => {\n /*\n * Auto connect may run this before the wallet is injected; it should never\n * throw.\n */\n try {\n const connectEvent = await getInstance().restoreConnection();\n return isTonConnectEventSuccess(connectEvent);\n } catch {\n return false;\n }\n };\n}\n\nexport function disconnect(getInstance: () => TonProviderApi) {\n return async () => {\n /*\n * Revoking the session on the wallet side is best effort; local state\n * cleanup should proceed even if it fails.\n */\n try {\n await getInstance().send({\n method: 'disconnect',\n params: [],\n id: nextTonRequestId(),\n });\n } catch {\n // ignore\n }\n };\n}\n\nexport const tonActions = { connect, canEagerConnect, disconnect };\n", "import type { TonProviderApi } from '../namespaces/ton/types.js';\n\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport { type TonActions, utils } from '@hub3js/tvm';\n\nimport { connectEventToCAIP } from '../namespaces/ton/utils.js';\n\n/*\n * OKX emits its non-standard `accountChanged` event without a documented\n * payload, so the switched address can't be read from the event. Because the\n * bridge is standard TON Connect, `format` re-reads the active account from the\n * instance via `restoreConnection` instead\n */\nexport const changeAccountSubscriber = (getInstance: () => TonProviderApi) =>\n new ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>()\n .getInstance(getInstance)\n .format(async (instance) => {\n try {\n const connectEvent = await instance.restoreConnection();\n return await connectEventToCAIP(connectEvent);\n } catch {\n // No active session after the switch \u2014 treat as disconnected.\n return utils.formatAccountsToCAIP([]);\n }\n })\n .addEventListener((instance, callback) => {\n instance.on('accountChanged', callback);\n })\n .removeEventListener((instance, callback) => {\n instance.off('accountChanged', callback);\n });\n\nexport const disconnectSubscriber = (getInstance: () => TonProviderApi) =>\n new ChangeAccountSubscriberBuilder<unknown, TonProviderApi, TonActions>()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n event.preventDefault();\n void context.action('disconnect');\n })\n .format(async () => [])\n .addEventListener((instance, callback) => {\n instance.on('disconnect', callback);\n })\n .removeEventListener((instance, callback) => {\n instance.off('disconnect', callback);\n });\n\nexport const tonBuilders = { changeAccountSubscriber, disconnectSubscriber };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { type TronActions } from '@rango-dev/wallets-core/namespaces/tron';\nimport { builders } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport { tronActions } from '../actions/tron.js';\nimport { tronBuilders } from '../builders/tron.js';\nimport { WALLET_ID } from '../constants.js';\nimport { tronOKX } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = tronBuilders\n .changeAccountSubscriber(tronOKX)\n .build();\n\nconst connect = builders\n .connect()\n .action(tronActions.connect)\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(tronActions.canEagerConnect)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<TronActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst tron = new NamespaceBuilder<TronActions>('Tron', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { tron };\n", "import { utils } from '@rango-dev/wallets-core/namespaces/tron';\n\nimport {\n TRON_OK_REQUEST_CODE,\n TRON_USER_REJECTION_CODE,\n} from '../constants.js';\nimport { tronOKX } from '../utils.js';\n\nconst connect = async () => {\n const instance = tronOKX();\n const accountsResult = await instance.request({\n method: 'tron_requestAccounts',\n });\n\n if (accountsResult?.code && accountsResult.code !== TRON_OK_REQUEST_CODE) {\n if (accountsResult.code === TRON_USER_REJECTION_CODE) {\n throw new Error('User rejected the request.');\n }\n throw new Error(\n accountsResult.message ?? 'Failed to connect to OKX Wallet Tron.'\n );\n }\n return utils.formatAccountsToCAIP([instance.tronWeb.defaultAddress.base58]);\n};\n\n/*\n * Wrapped in a try-catch in the case of wallet injection delay\n */\nconst canEagerConnect = async () => {\n try {\n const tronInstance = tronOKX();\n return !!tronInstance.ready;\n } catch {\n return false;\n }\n};\nexport const tronActions = { connect, canEagerConnect };\n", "import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n type ProviderAPI,\n type TronActions,\n utils,\n} from '@rango-dev/wallets-core/namespaces/tron';\n\nimport { isOkxTronMessageEvent } from '../utils.js';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<\n MessageEvent<unknown>,\n ProviderAPI,\n TronActions\n >()\n .getInstance(getInstance)\n .onSwitchAccount((event, context) => {\n const data = event.payload?.data;\n\n if (!isOkxTronMessageEvent(data)) {\n event.preventDefault();\n return;\n }\n\n const { action } = data.message;\n\n if (action === 'disconnect') {\n event.preventDefault();\n context.action('disconnect');\n return;\n }\n\n /*\n * Change account only on `accountsChanged` with a string address (`format`\n * reads it). Everything else \u2014 including `accountsChanged` with address\n * `false` (its disconnect is handled above) \u2014 is ignored.\n */\n if (\n action !== 'accountsChanged' ||\n typeof data.message.data?.address !== 'string'\n ) {\n event.preventDefault();\n }\n })\n .format(async (_, event) => {\n const data = event.data;\n const address =\n isOkxTronMessageEvent(data) && data.message.action === 'accountsChanged'\n ? data.message.data?.address\n : undefined;\n if (typeof address !== 'string') {\n throw new Error('No Tron address received from OKX Wallet.');\n }\n return utils.formatAccountsToCAIP([address]);\n })\n .addEventListener((_, callback) => {\n window.addEventListener('message', callback);\n })\n .removeEventListener((_, callback) => {\n window.removeEventListener('message', callback);\n });\n\nexport const tronBuilders = { changeAccountSubscriber };\n", "import type { SuiActions } from '@hub3js/sui';\n\nimport { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport { actions, builders, hooks } from '@hub3js/sui';\n\nimport { WALLET_ID, WALLET_NAME_IN_WALLET_STANDARD } from '../constants.js';\nimport { suiHooks } from '../hooks/sui.js';\nimport { suiWalletInstanceOrThrow } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n hooks.changeAccountSubscriber({\n name: WALLET_NAME_IN_WALLET_STANDARD,\n });\n\nconst [disconnectSubscriber, disconnectCleanup] = suiHooks.disconnectSubscriber(\n suiWalletInstanceOrThrow\n);\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(\n actions.canEagerConnect({\n name: WALLET_NAME_IN_WALLET_STANDARD,\n })\n )\n .build();\n\nconst connect = builders\n .connect({\n name: WALLET_NAME_IN_WALLET_STANDARD,\n })\n .before(changeAccountSubscriber)\n .before(disconnectSubscriber)\n .or(changeAccountCleanup)\n .or(disconnectCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<SuiActions>()\n .after(changeAccountCleanup)\n .after(disconnectCleanup)\n .build();\n\nconst sui = new NamespaceBuilder<SuiActions>('Sui', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { sui };\n", "import type { Subscriber, SubscriberCleanUp } from '@hub3js/core';\nimport type { ProviderAPI, SuiActions } from '@hub3js/sui';\n\n/*\n * OKX's Sui wallet-standard instance emits a `disconnect` event on its\n * `standard:events` feature when the user disconnects from the wallet UI.\n * Account switches come through `change` (handled by the core change\n * subscriber); disconnect is NOT surfaced there. The `disconnect` event is\n * undocumented in the wallet-standard types, which only declare `change`, hence\n * the cast on `.on`. `.on` returns an unsubscribe function that the cleanup invokes.\n */\nfunction disconnectSubscriber(\n getInstance: () => ProviderAPI\n): [Subscriber<SuiActions>, SubscriberCleanUp<SuiActions>] {\n let unsubscribe: (() => void) | void;\n\n return [\n (context) => {\n const instance = getInstance();\n\n if (!instance) {\n throw new Error(\n 'Trying to subscribe to your Sui wallet, but seems its instance is not available.'\n );\n }\n\n unsubscribe = (\n instance.features['standard:events'].on as (\n event: string,\n listener: (event: unknown) => void\n ) => () => void\n )('disconnect', () => {\n context.action('disconnect');\n });\n },\n (_context, err) => {\n if (typeof unsubscribe === 'function') {\n unsubscribe();\n }\n\n return err;\n },\n ];\n}\n\nexport const suiHooks = { disconnectSubscriber };\n", "import { NamespaceBuilder } from '@hub3js/core';\nimport * as commonBuilders from '@hub3js/std/builders';\nimport { standardizeAndThrowError } from '@hub3js/std/operators';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n utils,\n type UtxoActions,\n} from '@rango-dev/wallets-core/namespaces/utxo';\nimport { builders } from '@rango-dev/wallets-core/namespaces/utxo';\n\nimport { utxoBuilders } from '../builders/utxo.js';\nimport { WALLET_ID } from '../constants.js';\nimport { bitcoinOKX, getBitcoinAccounts } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] = utxoBuilders\n .changeAccountSubscriber(bitcoinOKX)\n .build();\n\nconst canEagerConnect = utxoBuilders.canEagerConnect(bitcoinOKX).build();\n\nconst connect = builders\n .connect()\n .action(async function () {\n const accountsResult = await getBitcoinAccounts();\n\n if (!accountsResult?.address) {\n throw new Error(\"Couldn't find any address!\");\n }\n return utils.formatAccountsToCAIP(\n [accountsResult.address],\n CAIP_BITCOIN_CHAIN_ID\n );\n })\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<UtxoActions>()\n .before(() => {\n bitcoinOKX().disconnect();\n })\n .after(changeAccountCleanup)\n .build();\n\nconst utxo = new NamespaceBuilder<UtxoActions>('UTXO', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .build();\n\nexport { utxo };\n", "import type { OkxBtcAddress } from '../types.js';\n\nimport { ActionBuilder } from '@hub3js/core';\nimport { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';\nimport {\n CAIP_BITCOIN_CHAIN_ID,\n type ProviderAPI,\n utils,\n type UtxoActions,\n} from '@rango-dev/wallets-core/namespaces/utxo';\n\nexport const changeAccountSubscriber = (getInstance: () => ProviderAPI) =>\n new ChangeAccountSubscriberBuilder<OkxBtcAddress, ProviderAPI, UtxoActions>()\n .getInstance(getInstance)\n /*\n * Okx wallet may call the `changeAccount` event with `null` value\n * but we shouldn't disconnect in this case.\n */\n .onSwitchAccount((event) => {\n if (!event.payload?.address) {\n event.preventDefault();\n }\n })\n\n .format(async (_, event) => {\n return utils.formatAccountsToCAIP(\n event ? [event.address] : [],\n CAIP_BITCOIN_CHAIN_ID\n );\n })\n .addEventListener((instance, callback) => {\n return instance.addListener('accountChanged', callback);\n })\n .removeEventListener((instance, callback) => {\n return instance.removeListener('accountChanged', callback);\n });\n\nfunction canEagerConnect(getInstance: () => ProviderAPI) {\n return new ActionBuilder<UtxoActions, 'canEagerConnect'>(\n 'canEagerConnect'\n ).action(async () => {\n const instance = getInstance();\n try {\n const accounts = await instance.getAccounts();\n return !!accounts.length;\n } catch {\n return false;\n }\n });\n}\n\nexport const utxoBuilders = { changeAccountSubscriber, canEagerConnect };\n"],
|
|
5
|
+
"mappings": "iFAAA,OAAS,kBAAAA,OAAsB,qBCE/B,OAAS,mBAAAC,OAAuB,eCAhC,OAAS,kBAAAC,MAAsB,iCAC/B,OAAS,YAAAC,OAAgB,4BACzB,OAEE,oBAAAC,GACA,iBAAAC,GAEA,mBAAAC,GAEA,kBAAAC,OACK,cCTP,OACE,iBAAAC,GACA,oBAAAC,GACA,kBAAAC,GACA,iBAAAC,GACA,kBAAAC,OACK,qBACP,OACE,iCAAAC,EACA,sBAAAC,MACK,4BACP,OAAS,wBAAAC,GAAsB,mBAAmBC,MAAc,cCdhE,OACE,uBAAAC,OAEK,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AAK,SAAUC,EAASC,EAA6B,CACpDC,EAAgBD,CAAY,EAC5B,GAAM,CAAC,CAAEE,CAAQ,EAAIH,EAAQ,MAAM,EAE/BI,EAAY,IACdD,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,2BAA4BH,CAAO,EAErD,CAAC,EACA,OAAO,WAAYK,EAAQ,EAC3B,IAAI,SAAUC,EAAM,EACpB,IAAI,MAAOC,EAAG,EACd,IAAI,OAAQC,EAAI,EAChB,IAAI,MAAOC,EAAG,EACd,IAAI,OAAQC,EAAI,EAChB,IAAI,MAAOC,EAAG,EAEd,MAAM,EAnBW,iBDVtB,IAAMC,GAAWC,EAAA,IACfC,GAAe,EAAE,QAAQ,QAASC,GAAc,CAAC,EAAE,MAAM,EAD1C",
|
|
6
|
+
"names": ["defineVersions", "ProviderBuilder", "LegacyNetworks", "Networks", "solanaBlockchain", "tonBlockchain", "TransactionType", "tronBlockchain", "EVM_NAMESPACE", "SOLANA_NAMESPACE", "UTXO_NAMESPACE", "TON_NAMESPACE", "TRON_NAMESPACE", "dynamicImportWithRefinedError", "getNetworkInstance", "DefaultSignerFactory", "TxType", "DefaultSolanaSigner", "SignerError", "SignerErrorCode", "OKXSolanaSigner", "DefaultSolanaSigner", "__name", "provider", "msg", "signature", "error", "SignerError", "SignerErrorCode", "dynamicImportWithRefinedError", "SignerError", "SignerErrorCode", "TonChainID", "tonCoreUtils", "dynamicImportWithRefinedError", "isTonConnectEventSuccess", "event", "__name", "isTonAddressItemReply", "item", "environments", "setEnvironments", "env", "getTonConnectManifestUrl", "manifestUrl", "tonRequestId", "nextTonRequestId", "connectEventToCAIP", "connectEvent", "tonCoreUtils", "addressItem", "Address", "dynamicImportWithRefinedError", "userFriendlyAddress", "toSignerError", "response", "code", "TON_CONNECT_USER_REJECTED_CODE", "SignerErrorCode", "SignerError", "__name", "OKXTonSigner", "provider", "tx", "validUntil", "network", "from", "messages", "Address", "Cell", "dynamicImportWithRefinedError", "transactionPayload", "TonChainID", "stateInit", "payload", "message", "nextTonRequestId", "error", "Networks", "SignerError", "OKXUTXOSigner", "__name", "provider", "SignerError", "tx", "asset", "psbt", "Networks", "psbtHex", "toSignInputs", "address", "signingIndexes", "index", "signedPsbtHex", "error", "EVM_NAMESPACE", "SOLANA_NAMESPACE", "TON_NAMESPACE", "TRON_NAMESPACE", "UTXO_NAMESPACE", "getSuiInstanceOrThrow", "okx", "okxwallet", "okxTonWallet", "instances", "EVM_NAMESPACE", "SOLANA_NAMESPACE", "UTXO_NAMESPACE", "TON_NAMESPACE", "TRON_NAMESPACE", "__name", "getInstanceOrThrow", "evmOKX", "evmInstance", "solanaOKX", "solanaInstance", "bitcoinOKX", "bitcoinInstance", "tonOKX", "tonInstance", "tronOKX", "tronInstance", "suiWalletInstance", "getSuiInstanceOrThrow", "WALLET_NAME_IN_WALLET_STANDARD", "suiWalletInstanceOrThrow", "getBitcoinAccounts", "requestResult", "isOkxTronMessageEvent", "value", "event", "getSigners", "provider", "ethProvider", "getNetworkInstance", "EVM_NAMESPACE", "solProvider", "SOLANA_NAMESPACE", "utxoProvider", "UTXO_NAMESPACE", "tonProvider", "TON_NAMESPACE", "tronProvider", "TRON_NAMESPACE", "signers", "DefaultSignerFactory", "DefaultEvmSigner", "dynamicImportWithRefinedError", "DefaultTronSigner", "TxType", "OKXSolanaSigner", "OKXUTXOSigner", "OKXTonSigner", "suiProvider", "suiWalletInstance", "DefaultSuiSigner", "__name", "WALLET_ID", "TON_CONNECT_PROTOCOL_VERSION", "TON_CONNECT_USER_REJECTED_CODE", "TRON_OK_REQUEST_CODE", "TRON_USER_REJECTION_CODE", "WALLET_NAME_IN_WALLET_STANDARD", "OKX_WALLET_SUPPORTED_CHAINS", "LegacyNetworks", "metadata", "allBlockchains", "blockchainMeta", "solanaBlockchain", "chain", "Networks", "tonBlockchain", "tronBlockchain", "TransactionType", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "actions", "builders", "utils", "commonBuilders", "standardizeAndThrowError", "changeAccountSubscriber", "changeAccountCleanup", "builders", "evmOKX", "event", "instance", "chainId", "utils", "connect", "actions", "standardizeAndThrowError", "disconnect", "canSwitchNetwork", "canEagerConnect", "getChainId", "evm", "NamespaceBuilder", "WALLET_ID", "ActionBuilder", "NamespaceBuilder", "actions", "builders", "utils", "commonBuilders", "standardizeAndThrowError", "changeAccountSubscriber", "changeAccountCleanup", "builders", "solanaOKX", "event", "_", "utils", "connect", "actions", "standardizeAndThrowError", "disconnect", "canEagerConnect", "ActionBuilder", "solana", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "builders", "connect", "getInstance", "instance", "connectEvent", "isTonConnectEventSuccess", "TON_CONNECT_PROTOCOL_VERSION", "getTonConnectManifestUrl", "TON_CONNECT_USER_REJECTED_CODE", "accounts", "connectEventToCAIP", "__name", "canEagerConnect", "disconnect", "nextTonRequestId", "tonActions", "ChangeAccountSubscriberBuilder", "utils", "changeAccountSubscriber", "__name", "getInstance", "ChangeAccountSubscriberBuilder", "instance", "connectEvent", "connectEventToCAIP", "utils", "callback", "disconnectSubscriber", "event", "context", "tonBuilders", "changeAccountSubscriber", "changeAccountCleanup", "tonBuilders", "tonOKX", "walletDisconnectSubscriber", "walletDisconnectCleanup", "connect", "builders", "tonActions", "standardizeAndThrowError", "disconnect", "canEagerConnect", "ton", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "builders", "utils", "connect", "__name", "instance", "tronOKX", "accountsResult", "TRON_OK_REQUEST_CODE", "TRON_USER_REJECTION_CODE", "utils", "canEagerConnect", "tronActions", "ChangeAccountSubscriberBuilder", "utils", "changeAccountSubscriber", "__name", "getInstance", "ChangeAccountSubscriberBuilder", "event", "context", "data", "isOkxTronMessageEvent", "action", "_", "address", "utils", "callback", "tronBuilders", "changeAccountSubscriber", "changeAccountCleanup", "tronBuilders", "tronOKX", "connect", "builders", "tronActions", "standardizeAndThrowError", "canEagerConnect", "disconnect", "tron", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "actions", "builders", "hooks", "disconnectSubscriber", "getInstance", "unsubscribe", "context", "instance", "_context", "err", "__name", "suiHooks", "changeAccountSubscriber", "changeAccountCleanup", "hooks", "WALLET_NAME_IN_WALLET_STANDARD", "disconnectSubscriber", "disconnectCleanup", "suiHooks", "suiWalletInstanceOrThrow", "canEagerConnect", "builders", "actions", "connect", "standardizeAndThrowError", "disconnect", "sui", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "CAIP_BITCOIN_CHAIN_ID", "utils", "builders", "ActionBuilder", "ChangeAccountSubscriberBuilder", "CAIP_BITCOIN_CHAIN_ID", "utils", "changeAccountSubscriber", "__name", "getInstance", "ChangeAccountSubscriberBuilder", "event", "_", "utils", "CAIP_BITCOIN_CHAIN_ID", "instance", "callback", "canEagerConnect", "ActionBuilder", "utxoBuilders", "changeAccountSubscriber", "changeAccountCleanup", "utxoBuilders", "bitcoinOKX", "canEagerConnect", "connect", "builders", "accountsResult", "getBitcoinAccounts", "utils", "CAIP_BITCOIN_CHAIN_ID", "standardizeAndThrowError", "disconnect", "utxo", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "environments", "setEnvironments", "setState", "okx", "metadata", "solana", "evm", "utxo", "ton", "tron", "sui", "versions", "__name", "defineVersions", "buildProvider"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sui.d.ts","sourceRoot":"","sources":["../../src/namespaces/sui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8C9C,QAAA,MAAM,GAAG,qDAIC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/ton.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"ton.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/ton.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAqCxD,QAAA,MAAM,GAAG,qDAIC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Environments, TonAddressItemReply, TonConnectEvent, TonConnectEventSuccess } from './types.js';
|
|
2
|
-
import type { CaipAccount } from '@
|
|
2
|
+
import type { CaipAccount } from '@hub3js/std/types';
|
|
3
3
|
export declare function isTonConnectEventSuccess(event: TonConnectEvent): event is TonConnectEventSuccess;
|
|
4
4
|
export declare function isTonAddressItemReply(item: unknown): item is TonAddressItemReply;
|
|
5
5
|
export declare function setEnvironments(env?: Environments): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/namespaces/ton/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,GACrB,KAAK,IAAI,sBAAsB,CAIjC;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,mBAAmB,CAS7B;AAID,wBAAgB,eAAe,CAAC,GAAG,CAAC,EAAE,YAAY,QAEjD;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAQjD;AAKD,wBAAgB,gBAAgB,IAAI,MAAM,CAGzC;AAGD,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,WAAW,EAAE,CAAC,CAmBxB"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const buildProvider: () => import("@hub3js/core").Provider<Record<"solana", import("@hub3js/solana").SolanaActions> & Record<"evm", import("@hub3js/evm").EvmActions> & Record<"utxo", import("@rango-dev/wallets-core/namespaces/utxo").UtxoActions> & Record<"ton", import("@
|
|
1
|
+
declare const buildProvider: () => import("@hub3js/core").Provider<Record<"solana", import("@hub3js/solana").SolanaActions> & Record<"evm", import("@hub3js/evm").EvmActions> & Record<"utxo", import("@rango-dev/wallets-core/namespaces/utxo").UtxoActions> & Record<"ton", import("@hub3js/tvm").TonActions> & Record<"tron", import("@rango-dev/wallets-core/namespaces/tron").TronActions> & Record<"sui", import("@hub3js/sui").SuiActions>>;
|
|
2
2
|
export { buildProvider };
|
|
3
3
|
//# sourceMappingURL=provider.d.ts.map
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,aAAa,uZAmBP,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/signer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoBjD,wBAA8B,UAAU,CACtC,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,aAAa,CAAC,CA6BxB"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { TonProviderApi } from './namespaces/ton/types.js';
|
|
|
2
2
|
import type { OkxBtcAddress, OkxTronMessageEvent, Provider } from './types.js';
|
|
3
3
|
import type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';
|
|
4
4
|
import type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';
|
|
5
|
+
import type { ProviderAPI as SuiProviderApi } from '@hub3js/sui';
|
|
5
6
|
import type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';
|
|
6
7
|
import type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';
|
|
7
8
|
export declare function okx(): Provider | null;
|
|
@@ -11,6 +12,8 @@ export declare function solanaOKX(): SolanaProviderApi;
|
|
|
11
12
|
export declare function bitcoinOKX(): UtxoProviderApi;
|
|
12
13
|
export declare function tonOKX(): TonProviderApi;
|
|
13
14
|
export declare function tronOKX(): TronProviderApi;
|
|
15
|
+
export declare function suiWalletInstance(): SuiProviderApi | null;
|
|
16
|
+
export declare function suiWalletInstanceOrThrow(): SuiProviderApi;
|
|
14
17
|
export declare function getBitcoinAccounts(): Promise<OkxBtcAddress>;
|
|
15
18
|
export declare function isOkxTronMessageEvent(value: unknown): value is OkxTronMessageEvent;
|
|
16
19
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d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C;AAED,wBAAgB,MAAM,IAAI,cAAc,CAWvC;AAED,wBAAgB,OAAO,IAAI,eAAe,CAWzC;AAED,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAMzD;AAED,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD;AACD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC,CASjE;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,mBAAmB,CAU9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-okx",
|
|
3
|
-
"version": "0.63.1-next.
|
|
3
|
+
"version": "0.63.1-next.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -26,8 +26,11 @@
|
|
|
26
26
|
"@hub3js/namespaces": "^0.2.2",
|
|
27
27
|
"@hub3js/solana": "^0.3.0",
|
|
28
28
|
"@hub3js/std": "^0.2.0",
|
|
29
|
+
"@hub3js/sui": "^0.2.3",
|
|
30
|
+
"@hub3js/tvm": "^0.2.3",
|
|
29
31
|
"@rango-dev/signer-evm": "^0.44.1-next.0",
|
|
30
32
|
"@rango-dev/signer-solana": "^0.48.1-next.0",
|
|
33
|
+
"@rango-dev/signer-sui": "^0.10.1-next.1",
|
|
31
34
|
"@rango-dev/signer-tron": "^0.41.1-next.0",
|
|
32
35
|
"@rango-dev/wallets-core": "^0.60.1-next.3",
|
|
33
36
|
"@rango-dev/wallets-shared": "^0.61.1-next.4",
|
|
@@ -37,4 +40,4 @@
|
|
|
37
40
|
"publishConfig": {
|
|
38
41
|
"access": "public"
|
|
39
42
|
}
|
|
40
|
-
}
|
|
43
|
+
}
|
package/readme.md
CHANGED
|
@@ -39,11 +39,6 @@ Supported networks :
|
|
|
39
39
|
The wallet only supports bitcoin.
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
#### 🚧 Sui
|
|
43
|
-
|
|
44
|
-
The wallet supports Sui, but it is **not implemented** in the current integration.
|
|
45
|
-
|
|
46
|
-
|
|
47
42
|
|
|
48
43
|
### Feature
|
|
49
44
|
|
|
@@ -59,6 +54,8 @@ with a **"Transaction Unavailable"** error.
|
|
|
59
54
|
|
|
60
55
|
#### ⚠️ Disconnect
|
|
61
56
|
|
|
57
|
+
Disconnecting from `evm` also disconnects `solana`, `tron`, `utxo` and `sui`. However, only `tron` and `sui` receive the disconnect event message.
|
|
58
|
+
`solana` and `utxo` will still appear as connected namespaces because they do not receive the disconnect event; they only disconnect after a page refresh.
|
|
62
59
|
The disconnect function will not work for this wallet, as it attempts to invoke disconnect on the connect method for private key imported wallets.
|
|
63
60
|
If the user disconnects the dApp from the wallet itself, we won't disconnect ourself. But we will get disconnected after refreshing the page.
|
|
64
61
|
If the user connects the wallet to one account, switches to another account, and then disconnects one of the two from the wallet, the dApp automatically switches to the remaining account that wasn’t disconnected.
|
|
@@ -74,6 +71,13 @@ Here’s the updated **Switch Account** section with a concise mention that conn
|
|
|
74
71
|
**Connection order also affects this behavior** depending on which namespace was connected first, some account updates may not propagate correctly across other namespaces. As a result, previously connected namespaces will not update automatically and require a manual disconnect and reconnect to sync the correct account.
|
|
75
72
|
|
|
76
73
|
Additionally, calling `connect` on a namespace that was already connected does not return the address of the newly selected account. To avoid leaving the user in an inconsistent state, we invoke a full wallet `disconnect` when the user disconnects the wallet from the provider.
|
|
74
|
+
An `evm` account switch might not be detected.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
#### ⚠️ Auto Connect
|
|
79
|
+
|
|
80
|
+
On auto connect in `sui` (e.g. page reload), the wallet reconnects to the account that was **first** connected, not the account the user last switched to. If the user connects one account, switches to another in the wallet, and the dApp later reconnects, the silent reconnect resolves the originally connected account rather than the currently active one. There is no client-side workaround, as the wallet exposes no way to read the active account at reconnect time.
|
|
77
81
|
|
|
78
82
|
|
|
79
83
|
---
|
package/src/actions/ton.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
} from '../namespaces/ton/types.js';
|
|
5
5
|
import type { Context, FunctionWithContext } from '@hub3js/core';
|
|
6
6
|
|
|
7
|
-
import { type TonActions } from '@
|
|
7
|
+
import { type TonActions } from '@hub3js/tvm';
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
TON_CONNECT_PROTOCOL_VERSION,
|
package/src/builders/ton.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TonProviderApi } from '../namespaces/ton/types.js';
|
|
2
2
|
|
|
3
3
|
import { ChangeAccountSubscriberBuilder } from '@hub3js/std/hooks';
|
|
4
|
-
import { type TonActions, utils } from '@
|
|
4
|
+
import { type TonActions, utils } from '@hub3js/tvm';
|
|
5
5
|
|
|
6
6
|
import { connectEventToCAIP } from '../namespaces/ton/utils.js';
|
|
7
7
|
|
package/src/constants.ts
CHANGED
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
type BlockchainMeta,
|
|
7
7
|
solanaBlockchain,
|
|
8
8
|
tonBlockchain,
|
|
9
|
+
type SuiBlockchainMeta,
|
|
10
|
+
TransactionType,
|
|
9
11
|
type TransferBlockchainMeta,
|
|
10
12
|
tronBlockchain,
|
|
11
13
|
} from 'rango-types';
|
|
@@ -19,6 +21,7 @@ export const TON_CONNECT_USER_REJECTED_CODE = 300;
|
|
|
19
21
|
export const TRON_OK_REQUEST_CODE = 200;
|
|
20
22
|
// EIP-1193 user-rejected-request code returned by `tron_requestAccounts`.
|
|
21
23
|
export const TRON_USER_REJECTION_CODE = 4001;
|
|
24
|
+
export const WALLET_NAME_IN_WALLET_STANDARD = 'OKX Wallet';
|
|
22
25
|
|
|
23
26
|
export const OKX_WALLET_SUPPORTED_CHAINS = [
|
|
24
27
|
LegacyNetworks.ETHEREUM,
|
|
@@ -95,6 +98,16 @@ export const metadata: ProviderMetadata = {
|
|
|
95
98
|
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
96
99
|
tronBlockchain(allBlockchains),
|
|
97
100
|
},
|
|
101
|
+
{
|
|
102
|
+
label: 'Sui',
|
|
103
|
+
value: 'Sui',
|
|
104
|
+
id: 'SUI',
|
|
105
|
+
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
106
|
+
allBlockchains.filter(
|
|
107
|
+
(chain): chain is SuiBlockchainMeta =>
|
|
108
|
+
chain.type === TransactionType.SUI
|
|
109
|
+
),
|
|
110
|
+
},
|
|
98
111
|
],
|
|
99
112
|
},
|
|
100
113
|
},
|
package/src/hooks/sui.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Subscriber, SubscriberCleanUp } from '@hub3js/core';
|
|
2
|
+
import type { ProviderAPI, SuiActions } from '@hub3js/sui';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* OKX's Sui wallet-standard instance emits a `disconnect` event on its
|
|
6
|
+
* `standard:events` feature when the user disconnects from the wallet UI.
|
|
7
|
+
* Account switches come through `change` (handled by the core change
|
|
8
|
+
* subscriber); disconnect is NOT surfaced there. The `disconnect` event is
|
|
9
|
+
* undocumented in the wallet-standard types, which only declare `change`, hence
|
|
10
|
+
* the cast on `.on`. `.on` returns an unsubscribe function that the cleanup invokes.
|
|
11
|
+
*/
|
|
12
|
+
function disconnectSubscriber(
|
|
13
|
+
getInstance: () => ProviderAPI
|
|
14
|
+
): [Subscriber<SuiActions>, SubscriberCleanUp<SuiActions>] {
|
|
15
|
+
let unsubscribe: (() => void) | void;
|
|
16
|
+
|
|
17
|
+
return [
|
|
18
|
+
(context) => {
|
|
19
|
+
const instance = getInstance();
|
|
20
|
+
|
|
21
|
+
if (!instance) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
'Trying to subscribe to your Sui wallet, but seems its instance is not available.'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
unsubscribe = (
|
|
28
|
+
instance.features['standard:events'].on as (
|
|
29
|
+
event: string,
|
|
30
|
+
listener: (event: unknown) => void
|
|
31
|
+
) => () => void
|
|
32
|
+
)('disconnect', () => {
|
|
33
|
+
context.action('disconnect');
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
(_context, err) => {
|
|
37
|
+
if (typeof unsubscribe === 'function') {
|
|
38
|
+
unsubscribe();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return err;
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const suiHooks = { disconnectSubscriber };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { SuiActions } from '@hub3js/sui';
|
|
2
|
+
|
|
3
|
+
import { NamespaceBuilder } from '@hub3js/core';
|
|
4
|
+
import * as commonBuilders from '@hub3js/std/builders';
|
|
5
|
+
import { standardizeAndThrowError } from '@hub3js/std/operators';
|
|
6
|
+
import { actions, builders, hooks } from '@hub3js/sui';
|
|
7
|
+
|
|
8
|
+
import { WALLET_ID, WALLET_NAME_IN_WALLET_STANDARD } from '../constants.js';
|
|
9
|
+
import { suiHooks } from '../hooks/sui.js';
|
|
10
|
+
import { suiWalletInstanceOrThrow } from '../utils.js';
|
|
11
|
+
|
|
12
|
+
const [changeAccountSubscriber, changeAccountCleanup] =
|
|
13
|
+
hooks.changeAccountSubscriber({
|
|
14
|
+
name: WALLET_NAME_IN_WALLET_STANDARD,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const [disconnectSubscriber, disconnectCleanup] = suiHooks.disconnectSubscriber(
|
|
18
|
+
suiWalletInstanceOrThrow
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const canEagerConnect = builders
|
|
22
|
+
.canEagerConnect()
|
|
23
|
+
.action(
|
|
24
|
+
actions.canEagerConnect({
|
|
25
|
+
name: WALLET_NAME_IN_WALLET_STANDARD,
|
|
26
|
+
})
|
|
27
|
+
)
|
|
28
|
+
.build();
|
|
29
|
+
|
|
30
|
+
const connect = builders
|
|
31
|
+
.connect({
|
|
32
|
+
name: WALLET_NAME_IN_WALLET_STANDARD,
|
|
33
|
+
})
|
|
34
|
+
.before(changeAccountSubscriber)
|
|
35
|
+
.before(disconnectSubscriber)
|
|
36
|
+
.or(changeAccountCleanup)
|
|
37
|
+
.or(disconnectCleanup)
|
|
38
|
+
.or(standardizeAndThrowError)
|
|
39
|
+
.build();
|
|
40
|
+
|
|
41
|
+
const disconnect = commonBuilders
|
|
42
|
+
.disconnect<SuiActions>()
|
|
43
|
+
.after(changeAccountCleanup)
|
|
44
|
+
.after(disconnectCleanup)
|
|
45
|
+
.build();
|
|
46
|
+
|
|
47
|
+
const sui = new NamespaceBuilder<SuiActions>('Sui', WALLET_ID)
|
|
48
|
+
.action(connect)
|
|
49
|
+
.action(disconnect)
|
|
50
|
+
.action(canEagerConnect)
|
|
51
|
+
.build();
|
|
52
|
+
|
|
53
|
+
export { sui };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { NamespaceBuilder } from '@hub3js/core';
|
|
2
2
|
import * as commonBuilders from '@hub3js/std/builders';
|
|
3
3
|
import { standardizeAndThrowError } from '@hub3js/std/operators';
|
|
4
|
-
import {
|
|
5
|
-
builders,
|
|
6
|
-
type TonActions,
|
|
7
|
-
} from '@rango-dev/wallets-core/namespaces/ton';
|
|
4
|
+
import { builders, type TonActions } from '@hub3js/tvm';
|
|
8
5
|
|
|
9
6
|
import { tonActions } from '../../actions/ton.js';
|
|
10
7
|
import { tonBuilders } from '../../builders/ton.js';
|
|
@@ -4,9 +4,9 @@ import type {
|
|
|
4
4
|
TonConnectEvent,
|
|
5
5
|
TonConnectEventSuccess,
|
|
6
6
|
} from './types.js';
|
|
7
|
-
import type { CaipAccount } from '@
|
|
7
|
+
import type { CaipAccount } from '@hub3js/std/types';
|
|
8
8
|
|
|
9
|
-
import { utils as tonCoreUtils } from '@
|
|
9
|
+
import { utils as tonCoreUtils } from '@hub3js/tvm';
|
|
10
10
|
import { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';
|
|
11
11
|
|
|
12
12
|
export function isTonConnectEventSuccess(
|
package/src/provider.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { solana } from './namespaces/solana.js';
|
|
|
8
8
|
import { ton } from './namespaces/ton/ton.js';
|
|
9
9
|
import { setEnvironments } from './namespaces/ton/utils.js';
|
|
10
10
|
import { tron } from './namespaces/tron.js';
|
|
11
|
+
import { sui } from './namespaces/sui.js';
|
|
11
12
|
import { utxo } from './namespaces/utxo.js';
|
|
12
13
|
import { okx as okxInstance } from './utils.js';
|
|
13
14
|
|
|
@@ -28,6 +29,7 @@ const buildProvider = () =>
|
|
|
28
29
|
.add('utxo', utxo)
|
|
29
30
|
.add('ton', ton)
|
|
30
31
|
.add('tron', tron)
|
|
32
|
+
.add('sui', sui)
|
|
31
33
|
|
|
32
34
|
.build();
|
|
33
35
|
|
package/src/signer.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
|
17
17
|
import { OKXSolanaSigner } from './signers/solana.js';
|
|
18
18
|
import { OKXTonSigner } from './signers/ton.js';
|
|
19
19
|
import { OKXUTXOSigner } from './signers/utxo.js';
|
|
20
|
+
import { suiWalletInstance } from './utils.js';
|
|
20
21
|
|
|
21
22
|
export default async function getSigners(
|
|
22
23
|
provider: Provider
|
|
@@ -40,5 +41,13 @@ export default async function getSigners(
|
|
|
40
41
|
signers.registerSigner(TxType.TON, new OKXTonSigner(tonProvider));
|
|
41
42
|
signers.registerSigner(TxType.TRON, new DefaultTronSigner(tronProvider));
|
|
42
43
|
|
|
44
|
+
const suiProvider = suiWalletInstance();
|
|
45
|
+
if (suiProvider) {
|
|
46
|
+
const { DefaultSuiSigner } = await dynamicImportWithRefinedError(
|
|
47
|
+
async () => await import('@rango-dev/signer-sui')
|
|
48
|
+
);
|
|
49
|
+
signers.registerSigner(TxType.SUI, new DefaultSuiSigner(suiProvider));
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
return signers;
|
|
44
53
|
}
|
package/src/utils.ts
CHANGED
|
@@ -2,16 +2,20 @@ import type { TonProviderApi } from './namespaces/ton/types.js';
|
|
|
2
2
|
import type { OkxBtcAddress, OkxTronMessageEvent, Provider } from './types.js';
|
|
3
3
|
import type { ProviderAPI as EvmProviderApi } from '@hub3js/evm';
|
|
4
4
|
import type { ProviderAPI as SolanaProviderApi } from '@hub3js/solana';
|
|
5
|
+
import type { ProviderAPI as SuiProviderApi } from '@hub3js/sui';
|
|
5
6
|
import type { ProviderAPI as TronProviderApi } from '@rango-dev/wallets-core/namespaces/tron';
|
|
6
7
|
import type { ProviderAPI as UtxoProviderApi } from '@rango-dev/wallets-core/namespaces/utxo';
|
|
7
8
|
|
|
8
9
|
import {
|
|
9
10
|
EVM_NAMESPACE,
|
|
10
11
|
SOLANA_NAMESPACE,
|
|
11
|
-
UTXO_NAMESPACE,
|
|
12
12
|
TON_NAMESPACE,
|
|
13
13
|
TRON_NAMESPACE,
|
|
14
|
+
UTXO_NAMESPACE,
|
|
14
15
|
} from '@hub3js/namespaces';
|
|
16
|
+
import { getInstanceOrThrow as getSuiInstanceOrThrow } from '@hub3js/sui';
|
|
17
|
+
|
|
18
|
+
import { WALLET_NAME_IN_WALLET_STANDARD } from './constants.js';
|
|
15
19
|
|
|
16
20
|
export function okx(): Provider | null {
|
|
17
21
|
const { okxwallet, okxTonWallet } = window;
|
|
@@ -111,6 +115,18 @@ export function tronOKX(): TronProviderApi {
|
|
|
111
115
|
|
|
112
116
|
return tronInstance;
|
|
113
117
|
}
|
|
118
|
+
|
|
119
|
+
export function suiWalletInstance(): SuiProviderApi | null {
|
|
120
|
+
try {
|
|
121
|
+
return getSuiInstanceOrThrow(WALLET_NAME_IN_WALLET_STANDARD);
|
|
122
|
+
} catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function suiWalletInstanceOrThrow(): SuiProviderApi {
|
|
128
|
+
return getSuiInstanceOrThrow(WALLET_NAME_IN_WALLET_STANDARD);
|
|
129
|
+
}
|
|
114
130
|
export async function getBitcoinAccounts(): Promise<OkxBtcAddress> {
|
|
115
131
|
const instance = bitcoinOKX();
|
|
116
132
|
const requestResult = await instance.connect();
|