@rango-dev/provider-solflare 0.1.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/provider-solflare.build.json +1 -0
- package/dist/signer.d.ts +4 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/signers/solanaSigner.d.ts +11 -0
- package/dist/signers/solanaSigner.d.ts.map +1 -0
- package/package.json +32 -0
- package/readme.md +1 -0
- package/src/index.ts +90 -0
- package/src/signer.ts +12 -0
- package/src/signers/solanaSigner.ts +27 -0
package/CHANGELOG.md
ADDED
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CanSwitchNetwork, Connect, Subscribe, WalletInfo } from '@rango-dev/wallets-shared';
|
|
2
|
+
import type { BlockchainMeta, SignerFactory } from 'rango-types';
|
|
3
|
+
import { WalletTypes } from '@rango-dev/wallets-shared';
|
|
4
|
+
import Solflare from '@solflare-wallet/sdk';
|
|
5
|
+
export declare const config: {
|
|
6
|
+
type: WalletTypes;
|
|
7
|
+
};
|
|
8
|
+
export declare const getInstance: () => Solflare | null;
|
|
9
|
+
export declare const connect: Connect;
|
|
10
|
+
export declare const subscribe: Subscribe;
|
|
11
|
+
export declare const canSwitchNetworkTo: CanSwitchNetwork;
|
|
12
|
+
export declare const getSigners: (provider: any) => SignerFactory;
|
|
13
|
+
export declare const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAY,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAO5C,eAAO,MAAM,MAAM;;CAElB,CAAC;AAIF,eAAO,MAAM,WAAW,uBAAkD,CAAC;AAC3E,eAAO,MAAM,OAAO,EAAE,OAoBrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,SAkBvB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAA8B,CAAC;AAEhE,eAAO,MAAM,UAAU,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,aAAsB,CAAC;AAEnE,eAAO,MAAM,aAAa,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,UAoBjE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var l=Object.defineProperty;var t=(e,o)=>l(e,"name",{value:o,configurable:!0});import{Networks as f,WalletTypes as m}from"@rango-dev/wallets-shared";import d from"@solflare-wallet/sdk";import{solanaBlockchain as S}from"rango-types";import{DefaultSignerFactory as p,TransactionType as h}from"rango-types";import{executeSolanaTransaction as g}from"@rango-dev/signer-solana";var n=class{static{t(this,"CustomSolanaSigner")}constructor(o){this.provider=o}async signMessage(o){let r=new TextEncoder().encode(o);return(await this.provider.signMessage(r,"utf8")).toString()}async signAndSendTx(o){return{hash:await g(o,this.provider)}}};function c(e){let o=new p;return o.registerSigner(h.SOLANA,new n(e)),o}t(c,"getSigners");var w=m.SOLFLARE,j={type:w},u=new d,B=t(()=>window.solflare?u:null,"getInstance"),N=t(async({instance:e})=>{try{if(await e.connect(),e.publicKey)return{accounts:[e.publicKey?.toString()],chainId:f.SOLANA};throw new Error}catch{throw new Error("An error occurred while connecting to Solflare.")}},"connect"),M=t(({instance:e,updateAccounts:o,disconnect:a})=>{let r=t(async s=>{if(s){let i=s.toString();o([i])}else a()},"handleAccountsChanged");return e?.on?.("accountChanged",r),()=>{e?.off?.("accountChanged",r)}},"subscribe"),O=t(()=>!1,"canSwitchNetworkTo"),W=c,R=t(e=>{let o=S(e);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:o}},"getWalletInfo");export{O as canSwitchNetworkTo,j as config,N as connect,B as getInstance,W as getSigners,R as getWalletInfo,M as subscribe};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/signer.ts", "../src/signers/solanaSigner.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';\n\nconst WALLET = WalletTypes.SOLFLARE;\n\nexport const config = {\n type: WALLET,\n};\n\nconst walletInstance = new Solflare();\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) => 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\nimport { CustomSolanaSigner } from './signers/solanaSigner';\n\nexport default function getSigners(provider: Solflare): SignerFactory {\n const signers = new DefaultSignerFactory();\n signers.registerSigner(TxType.SOLANA, new CustomSolanaSigner(provider));\n return signers;\n}\n", "import type Solflare from '@solflare-wallet/sdk';\nimport type { GenericSigner, SolanaTransaction } from 'rango-types';\n\nimport { executeSolanaTransaction } from '@rango-dev/signer-solana';\n\nexport class CustomSolanaSigner implements GenericSigner<SolanaTransaction> {\n private provider: any; // Used any instead of Solflare because there is an issue in type of `signTransaction` method of Solflare\n\n constructor(provider: Solflare) {\n this.provider = provider;\n }\n\n async signMessage(msg: string): Promise<string> {\n const encoder = new TextEncoder();\n const messageBytes = encoder.encode(msg);\n const messageSignature = await this.provider.signMessage(\n messageBytes,\n 'utf8'\n );\n return messageSignature.toString();\n }\n\n async signAndSendTx(tx: SolanaTransaction): Promise<{ hash: string }> {\n const hash = await executeSolanaTransaction(tx, this.provider);\n return { hash };\n }\n}\n"],
|
|
5
|
+
"mappings": "+EAQA,OAAS,YAAAA,EAAU,eAAAC,MAAmB,4BACtC,OAAOC,MAAc,uBACrB,OAAS,oBAAAC,MAAwB,cCPjC,OAAS,wBAAAC,EAAsB,mBAAmBC,MAAc,cCAhE,OAAS,4BAAAC,MAAgC,2BAElC,IAAMC,EAAN,KAAqE,CAL5E,MAK4E,CAAAC,EAAA,2BAG1E,YAAYC,EAAoB,CAC9B,KAAK,SAAWA,CAClB,CAEA,MAAM,YAAYC,EAA8B,CAE9C,IAAMC,EADU,IAAI,YAAY,EACH,OAAOD,CAAG,EAKvC,OAJyB,MAAM,KAAK,SAAS,YAC3CC,EACA,MACF,GACwB,SAAS,CACnC,CAEA,MAAM,cAAcC,EAAkD,CAEpE,MAAO,CAAE,KADI,MAAMC,EAAyBD,EAAI,KAAK,QAAQ,CAC/C,CAChB,CACF,EDnBe,SAARE,EAA4BC,EAAmC,CACpE,IAAMC,EAAU,IAAIC,EACpB,OAAAD,EAAQ,eAAeE,EAAO,OAAQ,IAAIC,EAAmBJ,CAAQ,CAAC,EAC/DC,CACT,CAJwBI,EAAAN,EAAA,cDOxB,IAAMO,EAASC,EAAY,SAEdC,EAAS,CACpB,KAAMF,CACR,EAEMG,EAAiB,IAAIC,EAEdC,EAAcC,EAAA,IAAO,OAAO,SAAWH,EAAiB,KAA1C,eACdI,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,EAA+CA,EAE/CC,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", "executeSolanaTransaction", "CustomSolanaSigner", "__name", "provider", "msg", "messageBytes", "tx", "executeSolanaTransaction", "getSigners", "provider", "signers", "DefaultSignerFactory", "TxType", "CustomSolanaSigner", "__name", "WALLET", "WalletTypes", "config", "walletInstance", "Solflare", "getInstance", "__name", "connect", "instance", "Networks", "subscribe", "updateAccounts", "disconnect", "handleAccountsChanged", "publicKey", "account", "canSwitchNetworkTo", "getSigners", "getWalletInfo", "allBlockChains", "solana", "solanaBlockchain"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/signers/solanaSigner.ts":{"bytes":924,"imports":[{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signer.ts":{"bytes":456,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signers/solanaSigner.ts","kind":"import-statement","original":"./signers/solanaSigner"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":2409,"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"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6200},"dist/index.js":{"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":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true}],"exports":["canSwitchNetworkTo","config","connect","getInstance","getSigners","getWalletInfo","subscribe"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":1318},"src/signer.ts":{"bytesInOutput":161},"src/signers/solanaSigner.ts":{"bytesInOutput":326}},"bytes":2043}}}
|
package/dist/signer.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAIpE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type Solflare from '@solflare-wallet/sdk';
|
|
2
|
+
import type { GenericSigner, SolanaTransaction } from 'rango-types';
|
|
3
|
+
export declare class CustomSolanaSigner implements GenericSigner<SolanaTransaction> {
|
|
4
|
+
private provider;
|
|
5
|
+
constructor(provider: Solflare);
|
|
6
|
+
signMessage(msg: string): Promise<string>;
|
|
7
|
+
signAndSendTx(tx: SolanaTransaction): Promise<{
|
|
8
|
+
hash: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=solanaSigner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solanaSigner.d.ts","sourceRoot":"","sources":["../../src/signers/solanaSigner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIpE,qBAAa,kBAAmB,YAAW,aAAa,CAAC,iBAAiB,CAAC;IACzE,OAAO,CAAC,QAAQ,CAAM;gBAEV,QAAQ,EAAE,QAAQ;IAIxB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUzC,aAAa,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAItE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rango-dev/provider-solflare",
|
|
3
|
+
"version": "0.1.1-next.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"source": "./src/index.ts",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"typings": "dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "node ../../scripts/build/command.mjs --path wallets/provider-solflare",
|
|
18
|
+
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
|
|
19
|
+
"clean": "rimraf dist",
|
|
20
|
+
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
21
|
+
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@rango-dev/signer-solana": "^0.30.1-next.2",
|
|
25
|
+
"@rango-dev/wallets-shared": "^0.35.2-next.2",
|
|
26
|
+
"@solflare-wallet/sdk": "^1.4.2",
|
|
27
|
+
"rango-types": "^0.1.69"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @rango-dev/provider-solflare
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CanSwitchNetwork,
|
|
3
|
+
Connect,
|
|
4
|
+
Subscribe,
|
|
5
|
+
WalletInfo,
|
|
6
|
+
} from '@rango-dev/wallets-shared';
|
|
7
|
+
import type { BlockchainMeta, SignerFactory } from 'rango-types';
|
|
8
|
+
|
|
9
|
+
import { Networks, WalletTypes } from '@rango-dev/wallets-shared';
|
|
10
|
+
import Solflare from '@solflare-wallet/sdk';
|
|
11
|
+
import { solanaBlockchain } from 'rango-types';
|
|
12
|
+
|
|
13
|
+
import signer from './signer';
|
|
14
|
+
|
|
15
|
+
const WALLET = WalletTypes.SOLFLARE;
|
|
16
|
+
|
|
17
|
+
export const config = {
|
|
18
|
+
type: WALLET,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const walletInstance = new Solflare();
|
|
22
|
+
|
|
23
|
+
export const getInstance = () => (window.solflare ? walletInstance : null);
|
|
24
|
+
export const connect: Connect = async ({
|
|
25
|
+
instance,
|
|
26
|
+
}: {
|
|
27
|
+
instance: Solflare;
|
|
28
|
+
}) => {
|
|
29
|
+
try {
|
|
30
|
+
await instance.connect();
|
|
31
|
+
|
|
32
|
+
if (instance.publicKey) {
|
|
33
|
+
const account = instance.publicKey?.toString();
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
accounts: [account],
|
|
37
|
+
chainId: Networks.SOLANA,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
throw new Error();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Error('An error occurred while connecting to Solflare.');
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const subscribe: Subscribe = ({
|
|
47
|
+
instance,
|
|
48
|
+
updateAccounts,
|
|
49
|
+
disconnect,
|
|
50
|
+
}) => {
|
|
51
|
+
const handleAccountsChanged = async (publicKey: string) => {
|
|
52
|
+
if (publicKey) {
|
|
53
|
+
const account = publicKey.toString();
|
|
54
|
+
updateAccounts([account]);
|
|
55
|
+
} else {
|
|
56
|
+
disconnect();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
instance?.on?.('accountChanged', handleAccountsChanged);
|
|
60
|
+
|
|
61
|
+
return () => {
|
|
62
|
+
instance?.off?.('accountChanged', handleAccountsChanged);
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const canSwitchNetworkTo: CanSwitchNetwork = () => false;
|
|
67
|
+
|
|
68
|
+
export const getSigners: (provider: any) => SignerFactory = signer;
|
|
69
|
+
|
|
70
|
+
export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
|
|
71
|
+
allBlockChains
|
|
72
|
+
) => {
|
|
73
|
+
const solana = solanaBlockchain(allBlockChains);
|
|
74
|
+
return {
|
|
75
|
+
name: 'Solflare',
|
|
76
|
+
img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/solflare/icon.svg',
|
|
77
|
+
installLink: {
|
|
78
|
+
CHROME:
|
|
79
|
+
'https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic',
|
|
80
|
+
BRAVE:
|
|
81
|
+
'https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic',
|
|
82
|
+
FIREFOX:
|
|
83
|
+
'https://addons.mozilla.org/en-US/firefox/addon/solflare-wallet/',
|
|
84
|
+
EDGE: 'https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic',
|
|
85
|
+
DEFAULT: 'https://solflare.com',
|
|
86
|
+
},
|
|
87
|
+
color: '#4d40c6',
|
|
88
|
+
supportedChains: solana,
|
|
89
|
+
};
|
|
90
|
+
};
|
package/src/signer.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type Solflare from '@solflare-wallet/sdk';
|
|
2
|
+
import type { SignerFactory } from 'rango-types';
|
|
3
|
+
|
|
4
|
+
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
5
|
+
|
|
6
|
+
import { CustomSolanaSigner } from './signers/solanaSigner';
|
|
7
|
+
|
|
8
|
+
export default function getSigners(provider: Solflare): SignerFactory {
|
|
9
|
+
const signers = new DefaultSignerFactory();
|
|
10
|
+
signers.registerSigner(TxType.SOLANA, new CustomSolanaSigner(provider));
|
|
11
|
+
return signers;
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type Solflare from '@solflare-wallet/sdk';
|
|
2
|
+
import type { GenericSigner, SolanaTransaction } from 'rango-types';
|
|
3
|
+
|
|
4
|
+
import { executeSolanaTransaction } from '@rango-dev/signer-solana';
|
|
5
|
+
|
|
6
|
+
export class CustomSolanaSigner implements GenericSigner<SolanaTransaction> {
|
|
7
|
+
private provider: any; // Used any instead of Solflare because there is an issue in type of `signTransaction` method of Solflare
|
|
8
|
+
|
|
9
|
+
constructor(provider: Solflare) {
|
|
10
|
+
this.provider = provider;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async signMessage(msg: string): Promise<string> {
|
|
14
|
+
const encoder = new TextEncoder();
|
|
15
|
+
const messageBytes = encoder.encode(msg);
|
|
16
|
+
const messageSignature = await this.provider.signMessage(
|
|
17
|
+
messageBytes,
|
|
18
|
+
'utf8'
|
|
19
|
+
);
|
|
20
|
+
return messageSignature.toString();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async signAndSendTx(tx: SolanaTransaction): Promise<{ hash: string }> {
|
|
24
|
+
const hash = await executeSolanaTransaction(tx, this.provider);
|
|
25
|
+
return { hash };
|
|
26
|
+
}
|
|
27
|
+
}
|