@rango-dev/provider-phantom 0.42.0 → 0.42.1-next.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # [0.42.0](https://github.com/rango-exchange/rango-client/compare/provider-phantom@0.41.0...provider-phantom@0.42.0) (2025-01-20)
2
+
3
+
4
+
1
5
  # [0.41.0](https://github.com/rango-exchange/rango-client/compare/provider-phantom@0.40.0...provider-phantom@0.41.0) (2024-12-30)
2
6
 
3
7
 
@@ -0,0 +1,6 @@
1
+ import { type ProviderInfo } from '@rango-dev/wallets-core';
2
+ import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
3
+ export declare const EVM_SUPPORTED_CHAINS: LegacyNetworks[];
4
+ export declare const WALLET_ID = "phantom";
5
+ export declare const info: ProviderInfo;
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,eAAO,MAAM,oBAAoB,kBAGhC,CAAC;AAEF,eAAO,MAAM,SAAS,YAAY,CAAC;AAEnC,eAAO,MAAM,IAAI,EAAE,YAelB,CAAC"}
@@ -1,15 +1,15 @@
1
- import type { CanEagerConnect, CanSwitchNetwork, Connect, Subscribe, WalletInfo } from '@rango-dev/wallets-shared';
1
+ import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
2
+ import type { Subscribe, WalletInfo } from '@rango-dev/wallets-shared';
2
3
  import type { BlockchainMeta, SignerFactory } from 'rango-types';
3
4
  import { WalletTypes } from '@rango-dev/wallets-shared';
4
- import { phantom as phantom_instance } from './helpers.js';
5
+ import { phantom as phantom_instance } from '../utils.js';
5
6
  export declare const config: {
6
7
  type: WalletTypes;
7
8
  };
8
9
  export declare const getInstance: typeof phantom_instance;
9
- export declare const connect: Connect;
10
10
  export declare const subscribe: Subscribe;
11
- export declare const canSwitchNetworkTo: CanSwitchNetwork;
12
11
  export declare const getSigners: (provider: any) => Promise<SignerFactory>;
13
- export declare const canEagerConnect: CanEagerConnect;
14
12
  export declare const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo;
13
+ declare const buildLegacyProvider: () => LegacyProviderInterface;
14
+ export { buildLegacyProvider };
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/legacy/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAIV,SAAS,EACT,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,cAAc,EAEd,aAAa,EACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAGL,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM1D,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,eAAO,MAAM,WAAW,yBAAmB,CAAC;AAiB5C,eAAO,MAAM,SAAS,EAAE,SAevB,CAAC;AAMF,eAAO,MAAM,UAAU,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,aAAa,CAAU,CAAC;AAW5E,eAAO,MAAM,aAAa,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,UA4CjE,CAAC;AAEF,QAAA,MAAM,mBAAmB,EAAE,MAAM,uBAS/B,CAAC;AAEH,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/legacy/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,wBAA8B,UAAU,CACtC,QAAQ,EAAE,GAAG,GACZ,OAAO,CAAC,aAAa,CAAC,CAUxB"}
package/dist/mod.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ declare const versions: () => import("@rango-dev/wallets-core/utils").VersionedProviders;
2
+ export { versions };
3
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,QAAQ,kEAIF,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/dist/mod.js ADDED
@@ -0,0 +1,2 @@
1
+ var k=Object.defineProperty;var t=(o,e)=>k(o,"name",{value:e,configurable:!0});import{defineVersions as io}from"@rango-dev/wallets-core/utils";import{LegacyNetworks as f}from"@rango-dev/wallets-core/legacy";import{chooseInstance as x,getSolanaAccounts as M,WalletTypes as T}from"@rango-dev/wallets-shared";import{isEvmBlockchain as O,solanaBlockchain as _}from"rango-types";import"@rango-dev/wallets-core";import{LegacyNetworks as g}from"@rango-dev/wallets-core/legacy";var m=[g.ETHEREUM,g.POLYGON],a="phantom",h={name:"Phantom",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa",homepage:"https://phantom.app/"},properties:[{name:"detached",value:["Solana","EVM"]}]};import{LegacyNetworks as l}from"@rango-dev/wallets-core/legacy";function c(){let{phantom:o}=window;if(!o)return null;let{solana:e,ethereum:r}=o,n=new Map;return r&&r.isPhantom&&n.set(l.ETHEREUM,r),e&&e.isPhantom&&n.set(l.SOLANA,e),n}t(c,"phantom");function p(){let e=c()?.get(l.ETHEREUM);if(!e)throw new Error("Phantom not injected or EVM not enabled. Please check your wallet.");return e}t(p,"evmPhantom");function u(){let e=c()?.get(l.SOLANA);if(!e)throw new Error("Phantom not injected or Solana not enabled. Please check your wallet.");return e}t(u,"solanaPhantom");import{LegacyNetworks as A}from"@rango-dev/wallets-core/legacy";import{getNetworkInstance as v}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as C,TransactionType as w}from"rango-types";async function d(o){let e=v(o,A.SOLANA),r=v(o,A.ETHEREUM),{DefaultEvmSigner:n}=await import("@rango-dev/signer-evm"),{DefaultSolanaSigner:i}=await import("@rango-dev/signer-solana"),s=new C;return s.registerSigner(w.SOLANA,new i(e)),s.registerSigner(w.EVM,new n(r)),s}t(d,"getSigners");var B=T.PHANTOM,D={type:B},H=c,V=t(async({instance:o,meta:e})=>{let r=o.get(f.SOLANA);return await M({instance:r,meta:e})},"connect"),W=t(({instance:o,updateAccounts:e,connect:r})=>{let n=t(async i=>{let s=f.SOLANA;if(i){let L=i.toString();e([L])}else r(s)},"handleAccountsChanged");return o?.on?.("accountChanged",n),()=>{o?.off?.("accountChanged",n)}},"subscribe"),j=t(({network:o})=>m.includes(o),"canSwitchNetworkTo"),R=d,U=t(async({instance:o,meta:e})=>{let r=x(o,e,f.SOLANA);try{return!!await r.connect({onlyIfTrusted:!0})}catch{return!1}},"canEagerConnect"),F=t(o=>{let e=_(o),r=o.filter(n=>O(n)&&m.includes(n.name));return{name:"Phantom",img:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg",installLink:{CHROME:"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa",DEFAULT:"https://phantom.app/"},color:"#4d40c6",supportedChains:[...e,...r.filter(n=>m.includes(n.name))],needsNamespace:{selection:"multiple",data:[{label:"EVM",value:"EVM",id:"ETH"},{label:"Solana",value:"Solana",id:"SOLANA"}]}}},"getWalletInfo"),E=t(()=>({config:D,getInstance:H,connect:V,subscribe:W,canSwitchNetworkTo:j,getSigners:R,getWalletInfo:F,canEagerConnect:U}),"buildLegacyProvider");import{ProviderBuilder as so}from"@rango-dev/wallets-core";import{NamespaceBuilder as G}from"@rango-dev/wallets-core";import{builders as Y}from"@rango-dev/wallets-core/namespaces/common";import{actions as S,builders as q}from"@rango-dev/wallets-core/namespaces/evm";var[z,P]=S.changeAccountSubscriber(p),J=q.connect().action(S.connect(p)).before(z).or(P).build(),Q=Y.disconnect().after(P).build(),y=new G("EVM",a).action(J).action(Q).build();import{NamespaceBuilder as X}from"@rango-dev/wallets-core";import{builders as Z}from"@rango-dev/wallets-core/namespaces/common";import{actions as $,builders as K,CAIP_NAMESPACE as oo,CAIP_SOLANA_CHAIN_ID as eo}from"@rango-dev/wallets-core/namespaces/solana";import{CAIP as no}from"@rango-dev/wallets-core/utils";import{getSolanaAccounts as to}from"@rango-dev/wallets-shared";var[ro,b]=$.changeAccountSubscriber(u),ao=K.connect().action(async function(){let o=u(),e=await to({instance:o,meta:[]});if(Array.isArray(e))throw new Error("Expecting solana response to be a single value, not an array.");return e.accounts.map(n=>no.AccountId.format({address:n,chainId:{namespace:oo,reference:eo}}))}).before(ro).or(b).build(),co=Z.disconnect().after(b).build(),I=new X("Solana",a).action(ao).action(co).build();var N=t(()=>new so(a).init(function(o){let[,e]=o.state();c()&&(e("installed",!0),console.debug("[phantom] instance detected.",o))}).config("info",h).add("solana",I).add("evm",y).build(),"buildProvider");var oe=t(()=>io().version("0.0.0",E()).version("1.0.0",N()).build(),"versions");export{oe as versions};
2
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/mod.ts", "../src/legacy/index.ts", "../src/constants.ts", "../src/utils.ts", "../src/legacy/signer.ts", "../src/provider.ts", "../src/namespaces/evm.ts", "../src/namespaces/solana.ts"],
4
+ "sourcesContent": ["import { defineVersions } from '@rango-dev/wallets-core/utils';\n\nimport { buildLegacyProvider } from './legacy/index.js';\nimport { buildProvider } from './provider.js';\n\nconst versions = () =>\n defineVersions()\n .version('0.0.0', buildLegacyProvider())\n .version('1.0.0', buildProvider())\n .build();\n\nexport { versions };\n", "import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';\nimport type {\n CanEagerConnect,\n CanSwitchNetwork,\n Connect,\n Subscribe,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport type {\n BlockchainMeta,\n EvmBlockchainMeta,\n SignerFactory,\n} from 'rango-types';\n\nimport { LegacyNetworks as Networks } from '@rango-dev/wallets-core/legacy';\nimport {\n chooseInstance,\n getSolanaAccounts,\n WalletTypes,\n} from '@rango-dev/wallets-shared';\nimport { isEvmBlockchain, solanaBlockchain } from 'rango-types';\n\nimport { EVM_SUPPORTED_CHAINS } from '../constants.js';\nimport { phantom as phantom_instance } from '../utils.js';\n\nimport signer from './signer.js';\n\nconst WALLET = WalletTypes.PHANTOM;\n\nexport const config = {\n type: WALLET,\n};\n\nexport const getInstance = phantom_instance;\n\n/*\n * NOTE: Phantom's Hub version has support for EVM as well since we are deprecating the legacy,\n * we just want to keep the implementation for some time and then legacy provider will be removed soon.\n * So we don't add new namespaces (like EVM) to legacy.\n */\nconst connect: Connect = async ({ instance, meta }) => {\n const solanaInstance = instance.get(Networks.SOLANA);\n const result = await getSolanaAccounts({\n instance: solanaInstance,\n meta,\n });\n\n return result;\n};\n\nexport const subscribe: Subscribe = ({ instance, updateAccounts, connect }) => {\n const handleAccountsChanged = async (publicKey: string) => {\n const network = Networks.SOLANA;\n if (publicKey) {\n const account = publicKey.toString();\n updateAccounts([account]);\n } else {\n connect(network);\n }\n };\n instance?.on?.('accountChanged', handleAccountsChanged);\n\n return () => {\n instance?.off?.('accountChanged', handleAccountsChanged);\n };\n};\n\nconst canSwitchNetworkTo: CanSwitchNetwork = ({ network }) => {\n return EVM_SUPPORTED_CHAINS.includes(network as Networks);\n};\n\nexport const getSigners: (provider: any) => Promise<SignerFactory> = signer;\n\nconst canEagerConnect: CanEagerConnect = async ({ instance, meta }) => {\n const solanaInstance = chooseInstance(instance, meta, Networks.SOLANA);\n try {\n const result = await solanaInstance.connect({ onlyIfTrusted: true });\n return !!result;\n } catch (error) {\n return false;\n }\n};\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const solana = solanaBlockchain(allBlockChains);\n const evms = allBlockChains.filter(\n (chain): chain is EvmBlockchainMeta =>\n isEvmBlockchain(chain) &&\n EVM_SUPPORTED_CHAINS.includes(chain.name as Networks)\n );\n\n return {\n name: 'Phantom',\n img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa',\n\n DEFAULT: 'https://phantom.app/',\n },\n color: '#4d40c6',\n // if you are adding a new namespace, don't forget to also update `properties`\n supportedChains: [\n ...solana,\n ...evms.filter((chain) =>\n EVM_SUPPORTED_CHAINS.includes(chain.name as Networks)\n ),\n ],\n\n needsNamespace: {\n selection: 'multiple',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n },\n {\n label: 'Solana',\n value: 'Solana',\n id: 'SOLANA',\n },\n ],\n },\n };\n};\n\nconst buildLegacyProvider: () => LegacyProviderInterface = () => ({\n config,\n getInstance,\n connect,\n subscribe,\n canSwitchNetworkTo,\n getSigners,\n getWalletInfo,\n canEagerConnect,\n});\n\nexport { buildLegacyProvider };\n", "import { type ProviderInfo } from '@rango-dev/wallets-core';\nimport { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\n\nexport const EVM_SUPPORTED_CHAINS = [\n LegacyNetworks.ETHEREUM,\n LegacyNetworks.POLYGON,\n];\n\nexport const WALLET_ID = 'phantom';\n\nexport const info: ProviderInfo = {\n name: 'Phantom',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa',\n homepage: 'https://phantom.app/',\n },\n properties: [\n {\n name: 'detached',\n // if you are adding a new namespace, don't forget to also update `getWalletInfo`\n value: ['Solana', 'EVM'],\n },\n ],\n};\n", "import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm';\nimport type { ProviderAPI as SolanaProviderApi } from '@rango-dev/wallets-core/namespaces/solana';\n\nimport { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\n\ntype Provider = Map<string, unknown>;\n\nexport function phantom(): Provider | null {\n const { phantom } = window;\n\n if (!phantom) {\n return null;\n }\n\n const { solana, ethereum } = phantom;\n\n const instances: Provider = new Map();\n\n if (ethereum && ethereum.isPhantom) {\n instances.set(LegacyNetworks.ETHEREUM, ethereum);\n }\n\n if (solana && solana.isPhantom) {\n instances.set(LegacyNetworks.SOLANA, solana);\n }\n\n return instances;\n}\n\nexport function evmPhantom(): EvmProviderApi {\n const instances = phantom();\n\n const evmInstance = instances?.get(LegacyNetworks.ETHEREUM);\n\n if (!evmInstance) {\n throw new Error(\n 'Phantom not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance as EvmProviderApi;\n}\n\nexport function solanaPhantom(): SolanaProviderApi {\n const instance = phantom();\n const solanaInstance = instance?.get(LegacyNetworks.SOLANA);\n\n if (!solanaInstance) {\n throw new Error(\n 'Phantom not injected or Solana not enabled. Please check your wallet.'\n );\n }\n\n return solanaInstance;\n}\n", "import type { SignerFactory } from 'rango-types';\n\nimport { LegacyNetworks as Networks } from '@rango-dev/wallets-core/legacy';\nimport { getNetworkInstance } from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nexport default async function getSigners(\n provider: any\n): Promise<SignerFactory> {\n const solProvider = getNetworkInstance(provider, Networks.SOLANA);\n const evmProvider = getNetworkInstance(provider, Networks.ETHEREUM);\n\n const { DefaultEvmSigner } = await import('@rango-dev/signer-evm');\n const { DefaultSolanaSigner } = await import('@rango-dev/signer-solana');\n const signers = new DefaultSignerFactory();\n signers.registerSigner(TxType.SOLANA, new DefaultSolanaSigner(solProvider));\n signers.registerSigner(TxType.EVM, new DefaultEvmSigner(evmProvider));\n return signers;\n}\n", "import { ProviderBuilder } from '@rango-dev/wallets-core';\n\nimport { info, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { solana } from './namespaces/solana.js';\nimport { phantom as phantomInstance } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context) {\n const [, setState] = context.state();\n\n if (phantomInstance()) {\n setState('installed', true);\n console.debug('[phantom] instance detected.', context);\n }\n })\n .config('info', info)\n .add('solana', solana)\n .add('evm', evm)\n .build();\n\nexport { buildProvider };\n", "import type { EvmActions } from '@rango-dev/wallets-core/namespaces/evm';\n\nimport { NamespaceBuilder } from '@rango-dev/wallets-core';\nimport { builders as commonBuilders } from '@rango-dev/wallets-core/namespaces/common';\nimport { actions, builders } from '@rango-dev/wallets-core/namespaces/evm';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmPhantom } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n actions.changeAccountSubscriber(evmPhantom);\n\n/*\n * TODO: If user imported a private key for EVM, it hasn't solana.\n * when trying to connect to solana for this user we go through `-32603` which is an internal error.\n * If phantom added an specific error code for this situation, we can consider handling the error here.\n * @see https://docs.phantom.app/solana/errors\n */\nconst connect = builders\n .connect()\n .action(actions.connect(evmPhantom))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .build();\n\nexport { evm };\n", "import type { CaipAccount } from '@rango-dev/wallets-core/namespaces/common';\nimport type { SolanaActions } from '@rango-dev/wallets-core/namespaces/solana';\n\nimport { NamespaceBuilder } from '@rango-dev/wallets-core';\nimport { builders as commonBuilders } from '@rango-dev/wallets-core/namespaces/common';\nimport {\n actions,\n builders,\n CAIP_NAMESPACE,\n CAIP_SOLANA_CHAIN_ID,\n} from '@rango-dev/wallets-core/namespaces/solana';\nimport { CAIP } from '@rango-dev/wallets-core/utils';\nimport { getSolanaAccounts } from '@rango-dev/wallets-shared';\n\nimport { WALLET_ID } from '../constants.js';\nimport { solanaPhantom } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n actions.changeAccountSubscriber(solanaPhantom);\n\n/*\n * TODO: If user imported a private key for EVM, it hasn't solana.\n * when trying to connect to solana for this user we go through `-32603` which is an internal error.\n * If phantom added an specific error code for this situation, we can consider handling the error here.\n * @see https://docs.phantom.app/solana/errors\n */\nconst connect = builders\n .connect()\n .action(async function () {\n const solanaInstance = solanaPhantom();\n const result = await getSolanaAccounts({\n instance: solanaInstance,\n meta: [],\n });\n if (Array.isArray(result)) {\n throw new Error(\n 'Expecting solana response to be a single value, not an array.'\n );\n }\n\n const formatAccounts = result.accounts.map(\n (account) =>\n CAIP.AccountId.format({\n address: account,\n chainId: {\n namespace: CAIP_NAMESPACE,\n reference: CAIP_SOLANA_CHAIN_ID,\n },\n }) as CaipAccount\n );\n\n return formatAccounts;\n })\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<SolanaActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .build();\n\nexport { solana };\n"],
5
+ "mappings": "+EAAA,OAAS,kBAAAA,OAAsB,gCCc/B,OAAS,kBAAkBC,MAAgB,iCAC3C,OACE,kBAAAC,EACA,qBAAAC,EACA,eAAAC,MACK,4BACP,OAAS,mBAAAC,EAAiB,oBAAAC,MAAwB,cCpBlD,MAAkC,0BAClC,OAAS,kBAAAC,MAAsB,iCAExB,IAAMC,EAAuB,CAClCD,EAAe,SACfA,EAAe,OACjB,EAEaE,EAAY,UAEZC,EAAqB,CAChC,KAAM,UACN,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,CACxB,IAAMC,EAAiBH,EAAc,EAC/BI,EAAS,MAAMC,GAAkB,CACrC,SAAUF,EACV,KAAM,CAAC,CACT,CAAC,EACD,GAAI,MAAM,QAAQC,CAAM,EACtB,MAAM,IAAI,MACR,+DACF,EAcF,OAXuBA,EAAO,SAAS,IACpCE,GACCC,GAAK,UAAU,OAAO,CACpB,QAASD,EACT,QAAS,CACP,UAAWE,GACX,UAAWC,EACb,CACF,CAAC,CACL,CAGF,CAAC,EACA,OAAOZ,EAAuB,EAC9B,GAAGC,CAAoB,EACvB,MAAM,EAEHY,GAAaC,EAChB,WAA0B,EAC1B,MAAMb,CAAoB,EAC1B,MAAM,EAEHc,EAAS,IAAIC,EAAgC,SAAUC,CAAS,EACnE,OAAOb,EAAO,EACd,OAAOS,EAAU,EACjB,MAAM,EF1DT,IAAMK,EAAgBC,EAAA,IACpB,IAAIC,GAAgBC,CAAS,EAC1B,KAAK,SAAUC,EAAS,CACvB,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EAE/BE,EAAgB,IAClBD,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,+BAAgCD,CAAO,EAEzD,CAAC,EACA,OAAO,OAAQG,CAAI,EACnB,IAAI,SAAUC,CAAM,EACpB,IAAI,MAAOC,CAAG,EACd,MAAM,EAbW,iBLFtB,IAAMC,GAAWC,EAAA,IACfC,GAAe,EACZ,QAAQ,QAASC,EAAoB,CAAC,EACtC,QAAQ,QAASC,EAAc,CAAC,EAChC,MAAM,EAJM",
6
+ "names": ["defineVersions", "Networks", "chooseInstance", "getSolanaAccounts", "WalletTypes", "isEvmBlockchain", "solanaBlockchain", "LegacyNetworks", "EVM_SUPPORTED_CHAINS", "WALLET_ID", "info", "LegacyNetworks", "phantom", "solana", "ethereum", "instances", "LegacyNetworks", "__name", "evmPhantom", "evmInstance", "solanaPhantom", "solanaInstance", "Networks", "getNetworkInstance", "DefaultSignerFactory", "TxType", "getSigners", "provider", "solProvider", "getNetworkInstance", "Networks", "evmProvider", "DefaultEvmSigner", "DefaultSolanaSigner", "signers", "DefaultSignerFactory", "TxType", "__name", "WALLET", "WalletTypes", "config", "getInstance", "phantom", "connect", "__name", "instance", "meta", "solanaInstance", "Networks", "getSolanaAccounts", "subscribe", "updateAccounts", "handleAccountsChanged", "publicKey", "network", "account", "canSwitchNetworkTo", "EVM_SUPPORTED_CHAINS", "getSigners", "canEagerConnect", "chooseInstance", "getWalletInfo", "allBlockChains", "solana", "solanaBlockchain", "evms", "chain", "isEvmBlockchain", "buildLegacyProvider", "ProviderBuilder", "NamespaceBuilder", "commonBuilders", "actions", "builders", "changeAccountSubscriber", "changeAccountCleanup", "actions", "evmPhantom", "connect", "builders", "disconnect", "commonBuilders", "evm", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "actions", "builders", "CAIP_NAMESPACE", "CAIP_SOLANA_CHAIN_ID", "CAIP", "getSolanaAccounts", "changeAccountSubscriber", "changeAccountCleanup", "actions", "solanaPhantom", "connect", "builders", "solanaInstance", "result", "getSolanaAccounts", "account", "CAIP", "CAIP_NAMESPACE", "CAIP_SOLANA_CHAIN_ID", "disconnect", "commonBuilders", "solana", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "setState", "phantom", "info", "solana", "evm", "versions", "__name", "defineVersions", "buildLegacyProvider", "buildProvider"]
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { EvmActions } from '@rango-dev/wallets-core/namespaces/evm';
2
+ declare const evm: import("@rango-dev/wallets-core").ProxiedNamespace<EvmActions>;
3
+ export { evm };
4
+ //# sourceMappingURL=evm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/namespaces/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AA8BzE,QAAA,MAAM,GAAG,gEAGC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { SolanaActions } from '@rango-dev/wallets-core/namespaces/solana';
2
+ declare const solana: import("@rango-dev/wallets-core").ProxiedNamespace<SolanaActions>;
3
+ export { solana };
4
+ //# sourceMappingURL=solana.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/namespaces/solana.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AA6D/E,QAAA,MAAM,MAAM,mEAGF,CAAC;AAEX,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"inputs":{"src/helpers.ts":{"bytes":185,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signer.ts":{"bytes":569,"imports":[{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1964,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/signer.ts","kind":"import-statement","original":"./signer.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":4893},"dist/index.js":{"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true}],"exports":["canEagerConnect","canSwitchNetworkTo","config","connect","getInstance","getSigners","getWalletInfo","subscribe"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":878},"src/helpers.ts":{"bytesInOutput":117},"src/signer.ts":{"bytesInOutput":323}},"bytes":1577}}}
1
+ {"inputs":{"src/constants.ts":{"bytes":755,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true}],"format":"esm"},"src/utils.ts":{"bytes":1336,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/signer.ts":{"bytes":863,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/signer-evm","kind":"dynamic-import","external":true},{"path":"@rango-dev/signer-solana","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/index.ts":{"bytes":3683,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants.js"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils.js"},{"path":"src/legacy/signer.ts","kind":"import-statement","original":"./signer.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/namespaces/evm.ts":{"bytes":1210,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/evm","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants.js"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils.js"}],"format":"esm"},"src/namespaces/solana.ts":{"bytes":2073,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/solana","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants.js"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils.js"}],"format":"esm"},"src/provider.ts":{"bytes":659,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"src/namespaces/evm.ts","kind":"import-statement","original":"./namespaces/evm.js"},{"path":"src/namespaces/solana.ts","kind":"import-statement","original":"./namespaces/solana.js"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/mod.ts":{"bytes":332,"imports":[{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"src/legacy/index.ts","kind":"import-statement","original":"./legacy/index.js"},{"path":"src/provider.ts","kind":"import-statement","original":"./provider.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":17794},"dist/mod.js":{"imports":[{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/signer-evm","kind":"dynamic-import","external":true},{"path":"@rango-dev/signer-solana","kind":"dynamic-import","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/solana","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true}],"exports":["versions"],"entryPoint":"src/mod.ts","inputs":{"src/mod.ts":{"bytesInOutput":144},"src/legacy/index.ts":{"bytesInOutput":1471},"src/constants.ts":{"bytesInOutput":440},"src/utils.ts":{"bytesInOutput":570},"src/legacy/signer.ts":{"bytesInOutput":485},"src/provider.ts":{"bytesInOutput":262},"src/namespaces/evm.ts":{"bytesInOutput":383},"src/namespaces/solana.ts":{"bytesInOutput":804}},"bytes":4694}}}
@@ -0,0 +1,3 @@
1
+ declare const buildProvider: () => import("@rango-dev/wallets-core").Provider;
2
+ export { buildProvider };
3
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,aAAa,kDAaP,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm';
2
+ import type { ProviderAPI as SolanaProviderApi } from '@rango-dev/wallets-core/namespaces/solana';
3
+ type Provider = Map<string, unknown>;
4
+ export declare function phantom(): Provider | null;
5
+ export declare function evmPhantom(): EvmProviderApi;
6
+ export declare function solanaPhantom(): SolanaProviderApi;
7
+ export {};
8
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAIlG,KAAK,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErC,wBAAgB,OAAO,IAAI,QAAQ,GAAG,IAAI,CAoBzC;AAED,wBAAgB,UAAU,IAAI,cAAc,CAY3C;AAED,wBAAgB,aAAa,IAAI,iBAAiB,CAWjD"}
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
2
  "name": "@rango-dev/provider-phantom",
3
- "version": "0.42.0",
3
+ "version": "0.42.1-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "source": "./src/index.ts",
7
- "main": "./dist/index.js",
6
+ "source": "./src/mod.ts",
7
+ "main": "./dist/mod.js",
8
8
  "exports": {
9
- ".": "./dist/index.js"
9
+ ".": "./dist/mod.js"
10
10
  },
11
- "typings": "dist/index.d.ts",
11
+ "typings": "dist/mod.d.ts",
12
12
  "files": [
13
13
  "dist",
14
14
  "src"
15
15
  ],
16
16
  "scripts": {
17
- "build": "node ../../scripts/build/command.mjs --path wallets/provider-phantom",
17
+ "build": "node ../../scripts/build/command.mjs --path wallets/provider-phantom --inputs src/mod.ts",
18
18
  "ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
19
19
  "clean": "rimraf dist",
20
20
  "format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
21
- "lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
21
+ "lint": "eslint \"**/*.{ts,tsx}\""
22
22
  },
23
23
  "dependencies": {
24
- "@rango-dev/signer-solana": "^0.36.0",
25
- "@rango-dev/wallets-shared": "^0.41.0",
24
+ "@rango-dev/signer-solana": "^0.36.1-next.0",
25
+ "@rango-dev/wallets-shared": "^0.41.1-next.2",
26
26
  "rango-types": "^0.1.74"
27
27
  },
28
28
  "publishConfig": {
@@ -0,0 +1,26 @@
1
+ import { type ProviderInfo } from '@rango-dev/wallets-core';
2
+ import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
3
+
4
+ export const EVM_SUPPORTED_CHAINS = [
5
+ LegacyNetworks.ETHEREUM,
6
+ LegacyNetworks.POLYGON,
7
+ ];
8
+
9
+ export const WALLET_ID = 'phantom';
10
+
11
+ export const info: ProviderInfo = {
12
+ name: 'Phantom',
13
+ icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg',
14
+ extensions: {
15
+ chrome:
16
+ 'https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa',
17
+ homepage: 'https://phantom.app/',
18
+ },
19
+ properties: [
20
+ {
21
+ name: 'detached',
22
+ // if you are adding a new namespace, don't forget to also update `getWalletInfo`
23
+ value: ['Solana', 'EVM'],
24
+ },
25
+ ],
26
+ };
@@ -0,0 +1,140 @@
1
+ import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
2
+ import type {
3
+ CanEagerConnect,
4
+ CanSwitchNetwork,
5
+ Connect,
6
+ Subscribe,
7
+ WalletInfo,
8
+ } from '@rango-dev/wallets-shared';
9
+ import type {
10
+ BlockchainMeta,
11
+ EvmBlockchainMeta,
12
+ SignerFactory,
13
+ } from 'rango-types';
14
+
15
+ import { LegacyNetworks as Networks } from '@rango-dev/wallets-core/legacy';
16
+ import {
17
+ chooseInstance,
18
+ getSolanaAccounts,
19
+ WalletTypes,
20
+ } from '@rango-dev/wallets-shared';
21
+ import { isEvmBlockchain, solanaBlockchain } from 'rango-types';
22
+
23
+ import { EVM_SUPPORTED_CHAINS } from '../constants.js';
24
+ import { phantom as phantom_instance } from '../utils.js';
25
+
26
+ import signer from './signer.js';
27
+
28
+ const WALLET = WalletTypes.PHANTOM;
29
+
30
+ export const config = {
31
+ type: WALLET,
32
+ };
33
+
34
+ export const getInstance = phantom_instance;
35
+
36
+ /*
37
+ * NOTE: Phantom's Hub version has support for EVM as well since we are deprecating the legacy,
38
+ * we just want to keep the implementation for some time and then legacy provider will be removed soon.
39
+ * So we don't add new namespaces (like EVM) to legacy.
40
+ */
41
+ const connect: Connect = async ({ instance, meta }) => {
42
+ const solanaInstance = instance.get(Networks.SOLANA);
43
+ const result = await getSolanaAccounts({
44
+ instance: solanaInstance,
45
+ meta,
46
+ });
47
+
48
+ return result;
49
+ };
50
+
51
+ export const subscribe: Subscribe = ({ instance, updateAccounts, connect }) => {
52
+ const handleAccountsChanged = async (publicKey: string) => {
53
+ const network = Networks.SOLANA;
54
+ if (publicKey) {
55
+ const account = publicKey.toString();
56
+ updateAccounts([account]);
57
+ } else {
58
+ connect(network);
59
+ }
60
+ };
61
+ instance?.on?.('accountChanged', handleAccountsChanged);
62
+
63
+ return () => {
64
+ instance?.off?.('accountChanged', handleAccountsChanged);
65
+ };
66
+ };
67
+
68
+ const canSwitchNetworkTo: CanSwitchNetwork = ({ network }) => {
69
+ return EVM_SUPPORTED_CHAINS.includes(network as Networks);
70
+ };
71
+
72
+ export const getSigners: (provider: any) => Promise<SignerFactory> = signer;
73
+
74
+ const canEagerConnect: CanEagerConnect = async ({ instance, meta }) => {
75
+ const solanaInstance = chooseInstance(instance, meta, Networks.SOLANA);
76
+ try {
77
+ const result = await solanaInstance.connect({ onlyIfTrusted: true });
78
+ return !!result;
79
+ } catch (error) {
80
+ return false;
81
+ }
82
+ };
83
+ export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
84
+ allBlockChains
85
+ ) => {
86
+ const solana = solanaBlockchain(allBlockChains);
87
+ const evms = allBlockChains.filter(
88
+ (chain): chain is EvmBlockchainMeta =>
89
+ isEvmBlockchain(chain) &&
90
+ EVM_SUPPORTED_CHAINS.includes(chain.name as Networks)
91
+ );
92
+
93
+ return {
94
+ name: 'Phantom',
95
+ img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg',
96
+ installLink: {
97
+ CHROME:
98
+ 'https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa',
99
+
100
+ DEFAULT: 'https://phantom.app/',
101
+ },
102
+ color: '#4d40c6',
103
+ // if you are adding a new namespace, don't forget to also update `properties`
104
+ supportedChains: [
105
+ ...solana,
106
+ ...evms.filter((chain) =>
107
+ EVM_SUPPORTED_CHAINS.includes(chain.name as Networks)
108
+ ),
109
+ ],
110
+
111
+ needsNamespace: {
112
+ selection: 'multiple',
113
+ data: [
114
+ {
115
+ label: 'EVM',
116
+ value: 'EVM',
117
+ id: 'ETH',
118
+ },
119
+ {
120
+ label: 'Solana',
121
+ value: 'Solana',
122
+ id: 'SOLANA',
123
+ },
124
+ ],
125
+ },
126
+ };
127
+ };
128
+
129
+ const buildLegacyProvider: () => LegacyProviderInterface = () => ({
130
+ config,
131
+ getInstance,
132
+ connect,
133
+ subscribe,
134
+ canSwitchNetworkTo,
135
+ getSigners,
136
+ getWalletInfo,
137
+ canEagerConnect,
138
+ });
139
+
140
+ export { buildLegacyProvider };
@@ -0,0 +1,19 @@
1
+ import type { SignerFactory } from 'rango-types';
2
+
3
+ import { LegacyNetworks as Networks } from '@rango-dev/wallets-core/legacy';
4
+ import { getNetworkInstance } from '@rango-dev/wallets-shared';
5
+ import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
6
+
7
+ export default async function getSigners(
8
+ provider: any
9
+ ): Promise<SignerFactory> {
10
+ const solProvider = getNetworkInstance(provider, Networks.SOLANA);
11
+ const evmProvider = getNetworkInstance(provider, Networks.ETHEREUM);
12
+
13
+ const { DefaultEvmSigner } = await import('@rango-dev/signer-evm');
14
+ const { DefaultSolanaSigner } = await import('@rango-dev/signer-solana');
15
+ const signers = new DefaultSignerFactory();
16
+ signers.registerSigner(TxType.SOLANA, new DefaultSolanaSigner(solProvider));
17
+ signers.registerSigner(TxType.EVM, new DefaultEvmSigner(evmProvider));
18
+ return signers;
19
+ }
package/src/mod.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineVersions } from '@rango-dev/wallets-core/utils';
2
+
3
+ import { buildLegacyProvider } from './legacy/index.js';
4
+ import { buildProvider } from './provider.js';
5
+
6
+ const versions = () =>
7
+ defineVersions()
8
+ .version('0.0.0', buildLegacyProvider())
9
+ .version('1.0.0', buildProvider())
10
+ .build();
11
+
12
+ export { versions };
@@ -0,0 +1,36 @@
1
+ import type { EvmActions } from '@rango-dev/wallets-core/namespaces/evm';
2
+
3
+ import { NamespaceBuilder } from '@rango-dev/wallets-core';
4
+ import { builders as commonBuilders } from '@rango-dev/wallets-core/namespaces/common';
5
+ import { actions, builders } from '@rango-dev/wallets-core/namespaces/evm';
6
+
7
+ import { WALLET_ID } from '../constants.js';
8
+ import { evmPhantom } from '../utils.js';
9
+
10
+ const [changeAccountSubscriber, changeAccountCleanup] =
11
+ actions.changeAccountSubscriber(evmPhantom);
12
+
13
+ /*
14
+ * TODO: If user imported a private key for EVM, it hasn't solana.
15
+ * when trying to connect to solana for this user we go through `-32603` which is an internal error.
16
+ * If phantom added an specific error code for this situation, we can consider handling the error here.
17
+ * @see https://docs.phantom.app/solana/errors
18
+ */
19
+ const connect = builders
20
+ .connect()
21
+ .action(actions.connect(evmPhantom))
22
+ .before(changeAccountSubscriber)
23
+ .or(changeAccountCleanup)
24
+ .build();
25
+
26
+ const disconnect = commonBuilders
27
+ .disconnect<EvmActions>()
28
+ .after(changeAccountCleanup)
29
+ .build();
30
+
31
+ const evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)
32
+ .action(connect)
33
+ .action(disconnect)
34
+ .build();
35
+
36
+ export { evm };
@@ -0,0 +1,68 @@
1
+ import type { CaipAccount } from '@rango-dev/wallets-core/namespaces/common';
2
+ import type { SolanaActions } from '@rango-dev/wallets-core/namespaces/solana';
3
+
4
+ import { NamespaceBuilder } from '@rango-dev/wallets-core';
5
+ import { builders as commonBuilders } from '@rango-dev/wallets-core/namespaces/common';
6
+ import {
7
+ actions,
8
+ builders,
9
+ CAIP_NAMESPACE,
10
+ CAIP_SOLANA_CHAIN_ID,
11
+ } from '@rango-dev/wallets-core/namespaces/solana';
12
+ import { CAIP } from '@rango-dev/wallets-core/utils';
13
+ import { getSolanaAccounts } from '@rango-dev/wallets-shared';
14
+
15
+ import { WALLET_ID } from '../constants.js';
16
+ import { solanaPhantom } from '../utils.js';
17
+
18
+ const [changeAccountSubscriber, changeAccountCleanup] =
19
+ actions.changeAccountSubscriber(solanaPhantom);
20
+
21
+ /*
22
+ * TODO: If user imported a private key for EVM, it hasn't solana.
23
+ * when trying to connect to solana for this user we go through `-32603` which is an internal error.
24
+ * If phantom added an specific error code for this situation, we can consider handling the error here.
25
+ * @see https://docs.phantom.app/solana/errors
26
+ */
27
+ const connect = builders
28
+ .connect()
29
+ .action(async function () {
30
+ const solanaInstance = solanaPhantom();
31
+ const result = await getSolanaAccounts({
32
+ instance: solanaInstance,
33
+ meta: [],
34
+ });
35
+ if (Array.isArray(result)) {
36
+ throw new Error(
37
+ 'Expecting solana response to be a single value, not an array.'
38
+ );
39
+ }
40
+
41
+ const formatAccounts = result.accounts.map(
42
+ (account) =>
43
+ CAIP.AccountId.format({
44
+ address: account,
45
+ chainId: {
46
+ namespace: CAIP_NAMESPACE,
47
+ reference: CAIP_SOLANA_CHAIN_ID,
48
+ },
49
+ }) as CaipAccount
50
+ );
51
+
52
+ return formatAccounts;
53
+ })
54
+ .before(changeAccountSubscriber)
55
+ .or(changeAccountCleanup)
56
+ .build();
57
+
58
+ const disconnect = commonBuilders
59
+ .disconnect<SolanaActions>()
60
+ .after(changeAccountCleanup)
61
+ .build();
62
+
63
+ const solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID)
64
+ .action(connect)
65
+ .action(disconnect)
66
+ .build();
67
+
68
+ export { solana };
@@ -0,0 +1,23 @@
1
+ import { ProviderBuilder } from '@rango-dev/wallets-core';
2
+
3
+ import { info, WALLET_ID } from './constants.js';
4
+ import { evm } from './namespaces/evm.js';
5
+ import { solana } from './namespaces/solana.js';
6
+ import { phantom as phantomInstance } from './utils.js';
7
+
8
+ const buildProvider = () =>
9
+ new ProviderBuilder(WALLET_ID)
10
+ .init(function (context) {
11
+ const [, setState] = context.state();
12
+
13
+ if (phantomInstance()) {
14
+ setState('installed', true);
15
+ console.debug('[phantom] instance detected.', context);
16
+ }
17
+ })
18
+ .config('info', info)
19
+ .add('solana', solana)
20
+ .add('evm', evm)
21
+ .build();
22
+
23
+ export { buildProvider };
package/src/utils.ts ADDED
@@ -0,0 +1,55 @@
1
+ import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm';
2
+ import type { ProviderAPI as SolanaProviderApi } from '@rango-dev/wallets-core/namespaces/solana';
3
+
4
+ import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
5
+
6
+ type Provider = Map<string, unknown>;
7
+
8
+ export function phantom(): Provider | null {
9
+ const { phantom } = window;
10
+
11
+ if (!phantom) {
12
+ return null;
13
+ }
14
+
15
+ const { solana, ethereum } = phantom;
16
+
17
+ const instances: Provider = new Map();
18
+
19
+ if (ethereum && ethereum.isPhantom) {
20
+ instances.set(LegacyNetworks.ETHEREUM, ethereum);
21
+ }
22
+
23
+ if (solana && solana.isPhantom) {
24
+ instances.set(LegacyNetworks.SOLANA, solana);
25
+ }
26
+
27
+ return instances;
28
+ }
29
+
30
+ export function evmPhantom(): EvmProviderApi {
31
+ const instances = phantom();
32
+
33
+ const evmInstance = instances?.get(LegacyNetworks.ETHEREUM);
34
+
35
+ if (!evmInstance) {
36
+ throw new Error(
37
+ 'Phantom not injected or EVM not enabled. Please check your wallet.'
38
+ );
39
+ }
40
+
41
+ return evmInstance as EvmProviderApi;
42
+ }
43
+
44
+ export function solanaPhantom(): SolanaProviderApi {
45
+ const instance = phantom();
46
+ const solanaInstance = instance?.get(LegacyNetworks.SOLANA);
47
+
48
+ if (!solanaInstance) {
49
+ throw new Error(
50
+ 'Phantom not injected or Solana not enabled. Please check your wallet.'
51
+ );
52
+ }
53
+
54
+ return solanaInstance;
55
+ }
package/dist/helpers.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function phantom(): any;
2
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,QAUtB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAGL,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAK3D,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,eAAO,MAAM,WAAW,yBAAmB,CAAC;AAC5C,eAAO,MAAM,OAAO,EAAE,OAA2B,CAAC;AAElD,eAAO,MAAM,SAAS,EAAE,SAevB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAA8B,CAAC;AAEhE,eAAO,MAAM,UAAU,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,OAAO,CAAC,aAAa,CAAU,CAAC;AAE5E,eAAO,MAAM,eAAe,EAAE,eAO7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,UAgBjE,CAAC"}
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- var l=Object.defineProperty;var n=(t,o)=>l(t,"name",{value:o,configurable:!0});import{getSolanaAccounts as w,Networks as y,WalletTypes as S}from"@rango-dev/wallets-shared";import{solanaBlockchain as d}from"rango-types";function s(){if("phantom"in window){let t=window.phantom?.solana;if(t?.isPhantom)return t}return null}n(s,"phantom");import{DefaultSolanaSigner as m}from"@rango-dev/signer-solana";import{getNetworkInstance as g,Networks as h}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as f,TransactionType as u}from"rango-types";async function r(t){let o=g(t,h.SOLANA),e=new f;return e.registerSigner(u.SOLANA,new m(o)),e}n(r,"getSigners");var C=S.PHANTOM,W={type:C},v=s,B=w,M=n(({instance:t,updateAccounts:o,connect:e})=>{let a=n(async c=>{let i=y.SOLANA;if(c){let p=c.toString();o([p])}else e(i)},"handleAccountsChanged");return t?.on?.("accountChanged",a),()=>{t?.off?.("accountChanged",a)}},"subscribe"),j=n(()=>!1,"canSwitchNetworkTo"),D=r,H=n(async({instance:t})=>{try{return!!await t.connect({onlyIfTrusted:!0})}catch{return!1}},"canEagerConnect"),R=n(t=>{let o=d(t);return{name:"Phantom",img:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg",installLink:{CHROME:"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa",DEFAULT:"https://phantom.app/"},color:"#4d40c6",supportedChains:o}},"getWalletInfo");export{H as canEagerConnect,j as canSwitchNetworkTo,W as config,B as connect,v as getInstance,D as getSigners,R as getWalletInfo,M as subscribe};
2
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.ts", "../src/helpers.ts", "../src/signer.ts"],
4
- "sourcesContent": ["import type {\n CanEagerConnect,\n CanSwitchNetwork,\n Connect,\n Subscribe,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\n\nimport {\n getSolanaAccounts,\n Networks,\n WalletTypes,\n} from '@rango-dev/wallets-shared';\nimport { solanaBlockchain } from 'rango-types';\n\nimport { phantom as phantom_instance } from './helpers.js';\nimport signer from './signer.js';\n\nconst WALLET = WalletTypes.PHANTOM;\n\nexport const config = {\n type: WALLET,\n};\n\nexport const getInstance = phantom_instance;\nexport const connect: Connect = getSolanaAccounts;\n\nexport const subscribe: Subscribe = ({ instance, updateAccounts, connect }) => {\n const handleAccountsChanged = async (publicKey: string) => {\n const network = Networks.SOLANA;\n if (publicKey) {\n const account = publicKey.toString();\n updateAccounts([account]);\n } else {\n connect(network);\n }\n };\n instance?.on?.('accountChanged', handleAccountsChanged);\n\n return () => {\n instance?.off?.('accountChanged', handleAccountsChanged);\n };\n};\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = () => false;\n\nexport const getSigners: (provider: any) => Promise<SignerFactory> = signer;\n\nexport const canEagerConnect: CanEagerConnect = async ({ instance }) => {\n try {\n const result = await instance.connect({ onlyIfTrusted: true });\n return !!result;\n } catch (error) {\n return false;\n }\n};\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const solana = solanaBlockchain(allBlockChains);\n return {\n name: 'Phantom',\n img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa',\n\n DEFAULT: 'https://phantom.app/',\n },\n color: '#4d40c6',\n supportedChains: solana,\n };\n};\n", "export function phantom() {\n if ('phantom' in window) {\n const instance = window.phantom?.solana;\n\n if (instance?.isPhantom) {\n return instance;\n }\n }\n\n return null;\n}\n", "import type { SignerFactory } from 'rango-types';\n\nimport { DefaultSolanaSigner } from '@rango-dev/signer-solana';\nimport { getNetworkInstance, Networks } from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nexport default async function getSigners(\n provider: any\n): Promise<SignerFactory> {\n const solProvider = getNetworkInstance(provider, Networks.SOLANA);\n const signers = new DefaultSignerFactory();\n signers.registerSigner(TxType.SOLANA, new DefaultSolanaSigner(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AK,CAAC,CAE/D,MAAgB,CACd,MAAO,EACT,CACF,EAPgD,mBASnCU,EAAkEX,EAC7EY,GACG,CACH,IAAMC,EAASC,EAAiBF,CAAc,EAC9C,MAAO,CACL,KAAM,UACN,IAAK,wFACL,YAAa,CACX,OACE,qFAEF,QAAS,sBACX,EACA,MAAO,UACP,gBAAiBC,CACnB,CACF,EAhB+E",
6
- "names": ["getSolanaAccounts", "Networks", "WalletTypes", "solanaBlockchain", "phantom", "instance", "__name", "DefaultSolanaSigner", "getNetworkInstance", "Networks", "DefaultSignerFactory", "TxType", "getSigners", "provider", "solProvider", "getNetworkInstance", "Networks", "signers", "DefaultSignerFactory", "TxType", "DefaultSolanaSigner", "__name", "WALLET", "WalletTypes", "config", "getInstance", "phantom", "connect", "getSolanaAccounts", "subscribe", "__name", "instance", "updateAccounts", "handleAccountsChanged", "publicKey", "network", "Networks", "account", "canSwitchNetworkTo", "getSigners", "canEagerConnect", "getWalletInfo", "allBlockChains", "solana", "solanaBlockchain"]
7
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,wBAA8B,UAAU,CACtC,QAAQ,EAAE,GAAG,GACZ,OAAO,CAAC,aAAa,CAAC,CAKxB"}
package/src/helpers.ts DELETED
@@ -1,11 +0,0 @@
1
- export function phantom() {
2
- if ('phantom' in window) {
3
- const instance = window.phantom?.solana;
4
-
5
- if (instance?.isPhantom) {
6
- return instance;
7
- }
8
- }
9
-
10
- return null;
11
- }
package/src/index.ts DELETED
@@ -1,75 +0,0 @@
1
- import type {
2
- CanEagerConnect,
3
- CanSwitchNetwork,
4
- Connect,
5
- Subscribe,
6
- WalletInfo,
7
- } from '@rango-dev/wallets-shared';
8
- import type { BlockchainMeta, SignerFactory } from 'rango-types';
9
-
10
- import {
11
- getSolanaAccounts,
12
- Networks,
13
- WalletTypes,
14
- } from '@rango-dev/wallets-shared';
15
- import { solanaBlockchain } from 'rango-types';
16
-
17
- import { phantom as phantom_instance } from './helpers.js';
18
- import signer from './signer.js';
19
-
20
- const WALLET = WalletTypes.PHANTOM;
21
-
22
- export const config = {
23
- type: WALLET,
24
- };
25
-
26
- export const getInstance = phantom_instance;
27
- export const connect: Connect = getSolanaAccounts;
28
-
29
- export const subscribe: Subscribe = ({ instance, updateAccounts, connect }) => {
30
- const handleAccountsChanged = async (publicKey: string) => {
31
- const network = Networks.SOLANA;
32
- if (publicKey) {
33
- const account = publicKey.toString();
34
- updateAccounts([account]);
35
- } else {
36
- connect(network);
37
- }
38
- };
39
- instance?.on?.('accountChanged', handleAccountsChanged);
40
-
41
- return () => {
42
- instance?.off?.('accountChanged', handleAccountsChanged);
43
- };
44
- };
45
-
46
- export const canSwitchNetworkTo: CanSwitchNetwork = () => false;
47
-
48
- export const getSigners: (provider: any) => Promise<SignerFactory> = signer;
49
-
50
- export const canEagerConnect: CanEagerConnect = async ({ instance }) => {
51
- try {
52
- const result = await instance.connect({ onlyIfTrusted: true });
53
- return !!result;
54
- } catch (error) {
55
- return false;
56
- }
57
- };
58
-
59
- export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
60
- allBlockChains
61
- ) => {
62
- const solana = solanaBlockchain(allBlockChains);
63
- return {
64
- name: 'Phantom',
65
- img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/phantom/icon.svg',
66
- installLink: {
67
- CHROME:
68
- 'https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa',
69
-
70
- DEFAULT: 'https://phantom.app/',
71
- },
72
- color: '#4d40c6',
73
- supportedChains: solana,
74
- };
75
- };
package/src/signer.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { SignerFactory } from 'rango-types';
2
-
3
- import { DefaultSolanaSigner } from '@rango-dev/signer-solana';
4
- import { getNetworkInstance, Networks } from '@rango-dev/wallets-shared';
5
- import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
6
-
7
- export default async function getSigners(
8
- provider: any
9
- ): Promise<SignerFactory> {
10
- const solProvider = getNetworkInstance(provider, Networks.SOLANA);
11
- const signers = new DefaultSignerFactory();
12
- signers.registerSigner(TxType.SOLANA, new DefaultSolanaSigner(solProvider));
13
- return signers;
14
- }
File without changes