@rango-dev/provider-solflare 0.3.1-next.7 → 0.4.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 +15 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/provider-solflare.build.json +1 -1
- package/package.json +4 -4
- package/src/index.ts +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [0.4.0](https://github.com/rango-exchange/rango-client/compare/provider-solflare@0.3.0...provider-solflare@0.4.0) (2024-10-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump sdk and fix type issues ([d442208](https://github.com/rango-exchange/rango-client/commit/d4422083bf5dd27d5f509ce1db7f9560d05428c8))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Performance Improvements
|
|
10
|
+
|
|
11
|
+
* enable code splitting in build process ([fe5a41e](https://github.com/rango-exchange/rango-client/commit/fe5a41e0e297298de11cd74ca5825544742aa03a))
|
|
12
|
+
* lazy load signer packages ([7b88f18](https://github.com/rango-exchange/rango-client/commit/7b88f1834f7b29b4b81ab6c81a07bb88e8ccf55c))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
1
16
|
# [0.3.0](https://github.com/rango-exchange/rango-client/compare/provider-solflare@0.2.0...provider-solflare@0.3.0) (2024-09-10)
|
|
2
17
|
|
|
3
18
|
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./chunk-DYCPFO4Y.js";import{Networks as
|
|
1
|
+
import{a as e}from"./chunk-DYCPFO4Y.js";import{Networks as g,WalletTypes as h}from"@rango-dev/wallets-shared";import r from"@solflare-wallet/sdk";import{solanaBlockchain as d}from"rango-types";import{DefaultSignerFactory as f,TransactionType as p}from"rango-types";async function a(o){let t=new f,{CustomSolanaSigner:n}=await import("./solanaSigner-WXZ5A3PQ.js");return t.registerSigner(p.SOLANA,new n(o)),t}e(a,"getSigners");var m=h.SOLFLARE,A={type:m},s=r;typeof r!="function"&&typeof r.default=="function"&&(s=r.default);var w=new s,E=e(()=>window.solflare?w:null,"getInstance"),F=e(async({instance:o})=>{try{if(await o.connect(),o.publicKey)return{accounts:[o.publicKey?.toString()],chainId:g.SOLANA};throw new Error}catch{throw new Error("An error occurred while connecting to Solflare.")}},"connect"),L=e(({instance:o,updateAccounts:t,disconnect:n})=>{let l=e(async c=>{if(c){let i=c.toString();t([i])}else n()},"handleAccountsChanged");return o?.on?.("accountChanged",l),()=>{o?.off?.("accountChanged",l)}},"subscribe"),T=e(()=>!1,"canSwitchNetworkTo"),I=a,j=e(o=>{let t=d(o);return{name:"Solflare",img:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/solflare/icon.svg",installLink:{CHROME:"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",BRAVE:"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",FIREFOX:"https://addons.mozilla.org/en-US/firefox/addon/solflare-wallet/",EDGE:"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",DEFAULT:"https://solflare.com"},color:"#4d40c6",supportedChains:t}},"getWalletInfo");export{T as canSwitchNetworkTo,A as config,F as connect,E as getInstance,I as getSigners,j as getWalletInfo,L as subscribe};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/signer.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n CanSwitchNetwork,\n Connect,\n Subscribe,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\n\nimport { Networks, WalletTypes } from '@rango-dev/wallets-shared';\nimport Solflare from '@solflare-wallet/sdk';\nimport { solanaBlockchain } from 'rango-types';\n\nimport signer from './signer.js';\n\nconst WALLET = WalletTypes.SOLFLARE;\n\nexport const config = {\n type: WALLET,\n};\n\nconst walletInstance = new
|
|
5
|
-
"mappings": "wCAQA,OAAS,YAAAA,EAAU,eAAAC,MAAmB,4BACtC,OAAOC,MAAc,uBACrB,OAAS,oBAAAC,MAAwB,cCPjC,OAAS,wBAAAC,EAAsB,mBAAmBC,MAAc,cAEhE,eAAOC,EACLC,EACwB,CACxB,IAAMC,EAAU,IAAIC,EACd,CAAE,mBAAAC,CAAmB,EAAI,KAAM,QAAO,4BAA2B,EACvE,OAAAF,EAAQ,eAAeG,EAAO,OAAQ,IAAID,EAAmBH,CAAQ,CAAC,EAC/DC,CACT,CAP8BI,EAAAN,EAAA,cDS9B,IAAMO,EAASC,EAAY,SAEdC,EAAS,CACpB,KAAMF,CACR,
|
|
6
|
-
"names": ["Networks", "WalletTypes", "Solflare", "solanaBlockchain", "DefaultSignerFactory", "TxType", "getSigners", "provider", "signers", "DefaultSignerFactory", "CustomSolanaSigner", "TxType", "__name", "WALLET", "WalletTypes", "config", "
|
|
4
|
+
"sourcesContent": ["import type {\n CanSwitchNetwork,\n Connect,\n Subscribe,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\n\nimport { Networks, WalletTypes } from '@rango-dev/wallets-shared';\nimport Solflare from '@solflare-wallet/sdk';\nimport { solanaBlockchain } from 'rango-types';\n\nimport signer from './signer.js';\n\nconst WALLET = WalletTypes.SOLFLARE;\n\nexport const config = {\n type: WALLET,\n};\n/*\n * Solflare is a transpiling ESM to CJS as well. It causes interop issues which is normally will be fixed using following code\n */\nlet SDK = Solflare;\nif (\n typeof Solflare !== 'function' &&\n // @ts-expect-error This import error is not visible to TypeScript\n typeof Solflare.default === 'function'\n) {\n SDK = (Solflare as unknown as { default: typeof Solflare }).default;\n}\nconst walletInstance = new SDK();\n\nexport const getInstance = () => (window.solflare ? walletInstance : null);\nexport const connect: Connect = async ({\n instance,\n}: {\n instance: Solflare;\n}) => {\n try {\n await instance.connect();\n\n if (instance.publicKey) {\n const account = instance.publicKey?.toString();\n\n return {\n accounts: [account],\n chainId: Networks.SOLANA,\n };\n }\n throw new Error();\n } catch (error) {\n throw new Error('An error occurred while connecting to Solflare.');\n }\n};\n\nexport const subscribe: Subscribe = ({\n instance,\n updateAccounts,\n disconnect,\n}) => {\n const handleAccountsChanged = async (publicKey: string) => {\n if (publicKey) {\n const account = publicKey.toString();\n updateAccounts([account]);\n } else {\n disconnect();\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 getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const solana = solanaBlockchain(allBlockChains);\n return {\n name: 'Solflare',\n img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/solflare/icon.svg',\n installLink: {\n CHROME:\n 'https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic',\n BRAVE:\n 'https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic',\n FIREFOX:\n 'https://addons.mozilla.org/en-US/firefox/addon/solflare-wallet/',\n EDGE: 'https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic',\n DEFAULT: 'https://solflare.com',\n },\n color: '#4d40c6',\n supportedChains: solana,\n };\n};\n", "import type Solflare from '@solflare-wallet/sdk';\nimport type { SignerFactory } from 'rango-types';\n\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nexport default async function getSigners(\n provider: Solflare\n): Promise<SignerFactory> {\n const signers = new DefaultSignerFactory();\n const { CustomSolanaSigner } = await import('./signers/solanaSigner.js');\n signers.registerSigner(TxType.SOLANA, new CustomSolanaSigner(provider));\n return signers;\n}\n"],
|
|
5
|
+
"mappings": "wCAQA,OAAS,YAAAA,EAAU,eAAAC,MAAmB,4BACtC,OAAOC,MAAc,uBACrB,OAAS,oBAAAC,MAAwB,cCPjC,OAAS,wBAAAC,EAAsB,mBAAmBC,MAAc,cAEhE,eAAOC,EACLC,EACwB,CACxB,IAAMC,EAAU,IAAIC,EACd,CAAE,mBAAAC,CAAmB,EAAI,KAAM,QAAO,4BAA2B,EACvE,OAAAF,EAAQ,eAAeG,EAAO,OAAQ,IAAID,EAAmBH,CAAQ,CAAC,EAC/DC,CACT,CAP8BI,EAAAN,EAAA,cDS9B,IAAMO,EAASC,EAAY,SAEdC,EAAS,CACpB,KAAMF,CACR,EAIIG,EAAMC,EAER,OAAOA,GAAa,YAEpB,OAAOA,EAAS,SAAY,aAE5BD,EAAOC,EAAqD,SAE9D,IAAMC,EAAiB,IAAIF,EAEdG,EAAcC,EAAA,IAAO,OAAO,SAAWF,EAAiB,KAA1C,eACdG,EAAmBD,EAAA,MAAO,CACrC,SAAAE,CACF,IAEM,CACJ,GAAI,CAGF,GAFA,MAAMA,EAAS,QAAQ,EAEnBA,EAAS,UAGX,MAAO,CACL,SAAU,CAHIA,EAAS,WAAW,SAAS,CAGzB,EAClB,QAASC,EAAS,MACpB,EAEF,MAAM,IAAI,KACZ,MAAgB,CACd,MAAM,IAAI,MAAM,iDAAiD,CACnE,CACF,EApBgC,WAsBnBC,EAAuBJ,EAAA,CAAC,CACnC,SAAAE,EACA,eAAAG,EACA,WAAAC,CACF,IAAM,CACJ,IAAMC,EAAwBP,EAAA,MAAOQ,GAAsB,CACzD,GAAIA,EAAW,CACb,IAAMC,EAAUD,EAAU,SAAS,EACnCH,EAAe,CAACI,CAAO,CAAC,CAC1B,MACEH,EAAW,CAEf,EAP8B,yBAQ9B,OAAAJ,GAAU,KAAK,iBAAkBK,CAAqB,EAE/C,IAAM,CACXL,GAAU,MAAM,iBAAkBK,CAAqB,CACzD,CACF,EAlBoC,aAoBvBG,EAAuCV,EAAA,IAAM,GAAN,sBAEvCW,EAAwDA,EAExDC,EAAkEZ,EAC7Ea,GACG,CACH,IAAMC,EAASC,EAAiBF,CAAc,EAC9C,MAAO,CACL,KAAM,WACN,IAAK,yFACL,YAAa,CACX,OACE,4FACF,MACE,4FACF,QACE,kEACF,KAAM,4FACN,QAAS,sBACX,EACA,MAAO,UACP,gBAAiBC,CACnB,CACF,EApB+E",
|
|
6
|
+
"names": ["Networks", "WalletTypes", "Solflare", "solanaBlockchain", "DefaultSignerFactory", "TxType", "getSigners", "provider", "signers", "DefaultSignerFactory", "CustomSolanaSigner", "TxType", "__name", "WALLET", "WalletTypes", "config", "SDK", "Solflare", "walletInstance", "getInstance", "__name", "connect", "instance", "Networks", "subscribe", "updateAccounts", "disconnect", "handleAccountsChanged", "publicKey", "account", "canSwitchNetworkTo", "getSigners", "getWalletInfo", "allBlockChains", "solana", "solanaBlockchain"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/signers/solanaSigner.ts":{"bytes":955,"imports":[{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true},{"path":"bs58","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signer.ts":{"bytes":489,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signers/solanaSigner.ts","kind":"dynamic-import","original":"./signers/solanaSigner.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/signers/solanaSigner.ts":{"bytes":955,"imports":[{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true},{"path":"bs58","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signer.ts":{"bytes":489,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signers/solanaSigner.ts","kind":"dynamic-import","original":"./signers/solanaSigner.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":2797,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@solflare-wallet/sdk","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"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":5313},"dist/index.js":{"imports":[{"path":"dist/chunk-DYCPFO4Y.js","kind":"import-statement"},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@solflare-wallet/sdk","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"dist/solanaSigner-WXZ5A3PQ.js","kind":"dynamic-import"}],"exports":["canSwitchNetworkTo","config","connect","getInstance","getSigners","getWalletInfo","subscribe"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":1392},"src/signer.ts":{"bytesInOutput":233}},"bytes":1824},"dist/solanaSigner-WXZ5A3PQ.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1642},"dist/solanaSigner-WXZ5A3PQ.js":{"imports":[{"path":"dist/chunk-DYCPFO4Y.js","kind":"import-statement"},{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true},{"path":"bs58","kind":"import-statement","external":true}],"exports":["CustomSolanaSigner"],"entryPoint":"src/signers/solanaSigner.ts","inputs":{"src/signers/solanaSigner.ts":{"bytesInOutput":357}},"bytes":480},"dist/chunk-DYCPFO4Y.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/chunk-DYCPFO4Y.js":{"imports":[],"exports":["a"],"inputs":{},"bytes":138}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-solflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@rango-dev/signer-solana": "^0.
|
|
25
|
-
"@rango-dev/wallets-shared": "^0.
|
|
24
|
+
"@rango-dev/signer-solana": "^0.33.0",
|
|
25
|
+
"@rango-dev/wallets-shared": "^0.38.0",
|
|
26
26
|
"@solflare-wallet/sdk": "^1.4.2",
|
|
27
27
|
"bs58": "^5.0.0",
|
|
28
28
|
"rango-types": "^0.1.74"
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -17,8 +17,18 @@ const WALLET = WalletTypes.SOLFLARE;
|
|
|
17
17
|
export const config = {
|
|
18
18
|
type: WALLET,
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
/*
|
|
21
|
+
* Solflare is a transpiling ESM to CJS as well. It causes interop issues which is normally will be fixed using following code
|
|
22
|
+
*/
|
|
23
|
+
let SDK = Solflare;
|
|
24
|
+
if (
|
|
25
|
+
typeof Solflare !== 'function' &&
|
|
26
|
+
// @ts-expect-error This import error is not visible to TypeScript
|
|
27
|
+
typeof Solflare.default === 'function'
|
|
28
|
+
) {
|
|
29
|
+
SDK = (Solflare as unknown as { default: typeof Solflare }).default;
|
|
30
|
+
}
|
|
31
|
+
const walletInstance = new SDK();
|
|
22
32
|
|
|
23
33
|
export const getInstance = () => (window.solflare ? walletInstance : null);
|
|
24
34
|
export const connect: Connect = async ({
|