@rango-dev/provider-braavos 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.
@@ -0,0 +1,2 @@
1
+ export declare function getBraavosInstance(): any;
2
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,QAIjC"}
@@ -0,0 +1,15 @@
1
+ import { WalletTypes, CanSwitchNetwork, Connect, Subscribe, WalletInfo, Networks, CanEagerConnect } from '@rango-dev/wallets-shared';
2
+ import { SignerFactory, BlockchainMeta } from 'rango-types';
3
+ import { getBraavosInstance } from './helpers';
4
+ export declare const config: {
5
+ type: WalletTypes;
6
+ defaultNetwork: Networks;
7
+ };
8
+ export declare const getInstance: typeof getBraavosInstance;
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 canEagerConnect: CanEagerConnect;
14
+ export declare const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,UAAU,EACV,QAAQ,EACR,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAK/C,eAAO,MAAM,MAAM;;;CAGlB,CAAC;AAEF,eAAO,MAAM,WAAW,2BAAqB,CAAC;AAE9C,eAAO,MAAM,OAAO,EAAE,OAOrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,SAQvB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAA8B,CAAC;AAEhE,eAAO,MAAM,UAAU,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,aAAsB,CAAC;AAEnE,eAAO,MAAM,eAAe,EAAE,eACF,CAAC;AAE7B,eAAO,MAAM,aAAa,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,UAoBjE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ var i=Object.defineProperty;var o=(e,t)=>i(e,"name",{value:t,configurable:!0});import{WalletTypes as p,Networks as r}from"@rango-dev/wallets-shared";import{starknetBlockchain as h}from"rango-types";function a(){let{starknet_braavos:e}=window;return e||null}o(a,"getBraavosInstance");import{DefaultStarknetSigner as l}from"@rango-dev/signer-starknet";import{DefaultSignerFactory as g,TransactionType as m}from"rango-types";function n(e){let t=new g;return t.registerSigner(m.STARKNET,new l(e)),t}o(n,"getSigners");var f=p.BRAAVOS,W={type:f,defaultNetwork:r.STARKNET},D=a,K=o(async({instance:e})=>{let t=await e?.enable();if(!t?.length||!e.isConnected)throw new Error("Connection Error");return{accounts:t||[],chainId:r.STARKNET}},"connect"),L=o(({instance:e,state:t,updateAccounts:c})=>{e?.on("accountsChanged",s=>{t.connected&&e&&c([s],r.STARKNET)})},"subscribe"),M=o(()=>!1,"canSwitchNetworkTo"),O=n,z=o(({instance:e})=>e.isPreauthorized(),"canEagerConnect"),U=o(e=>{let t=h(e);return{name:"Braavos",img:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/braavos.png",installLink:{CHROME:"https://chrome.google.com/webstore/detail/braavos-smart-wallet/jnlgamecbpmbajjfhmmmlhejkemejdma",BRAVE:"https://chrome.google.com/webstore/detail/braavos-smart-wallet/jnlgamecbpmbajjfhmmmlhejkemejdma",FIREFOX:"https://addons.mozilla.org/en-US/firefox/addon/braavos-wallet/",EDGE:"https://microsoftedge.microsoft.com/addons/detail/braavos-wallet/hkkpjehhcnhgefhbdcgfkeegglpjchdc",DEFAULT:"https://braavos.app/"},color:"#96e7ed",supportedChains:t}},"getWalletInfo");export{z as canEagerConnect,M as canSwitchNetworkTo,W as config,K as connect,D as getInstance,O as getSigners,U as getWalletInfo,L as subscribe};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/helpers.ts", "../src/signer.ts"],
4
+ "sourcesContent": ["import {\n WalletTypes,\n CanSwitchNetwork,\n Connect,\n Subscribe,\n WalletInfo,\n Networks,\n CanEagerConnect,\n} from '@rango-dev/wallets-shared';\nimport { SignerFactory, BlockchainMeta, starknetBlockchain } from 'rango-types';\nimport { getBraavosInstance } from './helpers';\nimport signer from './signer';\n\nconst WALLET = WalletTypes.BRAAVOS;\n\nexport const config = {\n type: WALLET,\n defaultNetwork: Networks.STARKNET,\n};\n\nexport const getInstance = getBraavosInstance;\n\nexport const connect: Connect = async ({ instance }) => {\n const accounts = await instance?.enable();\n if (!accounts?.length || !instance.isConnected) {\n throw new Error('Connection Error');\n }\n\n return { accounts: accounts || [], chainId: Networks.STARKNET };\n};\n\nexport const subscribe: Subscribe = ({ instance, state, updateAccounts }) => {\n instance?.on('accountsChanged', (accounts: any) => {\n if (state.connected) {\n if (instance) {\n updateAccounts([accounts], Networks.STARKNET);\n }\n }\n });\n};\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = () => false;\n\nexport const getSigners: (provider: any) => SignerFactory = signer;\n\nexport const canEagerConnect: CanEagerConnect = ({ instance }) =>\n instance.isPreauthorized();\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const starknet = starknetBlockchain(allBlockChains);\n return {\n name: 'Braavos',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/braavos.png',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/braavos-smart-wallet/jnlgamecbpmbajjfhmmmlhejkemejdma',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/braavos-smart-wallet/jnlgamecbpmbajjfhmmmlhejkemejdma',\n FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/braavos-wallet/',\n EDGE: 'https://microsoftedge.microsoft.com/addons/detail/braavos-wallet/hkkpjehhcnhgefhbdcgfkeegglpjchdc',\n DEFAULT: 'https://braavos.app/',\n },\n\n color: '#96e7ed',\n supportedChains: starknet,\n };\n};\n", "export function getBraavosInstance() {\n const { starknet_braavos } = window;\n if (!!starknet_braavos) return starknet_braavos;\n return null;\n}\n", "import { DefaultStarknetSigner } from '@rango-dev/signer-starknet';\nimport {\n DefaultSignerFactory,\n SignerFactory,\n TransactionType as TxType,\n} from 'rango-types';\n\nexport default function getSigners(provider: any): SignerFactory {\n const signers = new DefaultSignerFactory();\n signers.registerSigner(TxType.STARKNET, new DefaultStarknetSigner(provider));\n return signers;\n}\n"],
5
+ "mappings": "+EAAA,OACE,eAAAA,EAKA,YAAAC,MAEK,4BACP,OAAwC,sBAAAC,MAA0B,cCT3D,SAASC,GAAqB,CACnC,GAAM,CAAE,iBAAAC,CAAiB,EAAI,OAC7B,OAAMA,GACC,IACT,CAJgBC,EAAAF,EAAA,sBCAhB,OAAS,yBAAAG,MAA6B,6BACtC,OACE,wBAAAC,EAEA,mBAAmBC,MACd,cAEQ,SAARC,EAA4BC,EAA8B,CAC/D,IAAMC,EAAU,IAAIC,EACpB,OAAAD,EAAQ,eAAeE,EAAO,SAAU,IAAIC,EAAsBJ,CAAQ,CAAC,EACpEC,CACT,CAJwBI,EAAAN,EAAA,cFMxB,IAAMO,EAASC,EAAY,QAEdC,EAAS,CACpB,KAAMF,EACN,eAAgBG,EAAS,QAC3B,EAEaC,EAAcC,EAEdC,EAAmBC,EAAA,MAAO,CAAE,SAAAC,CAAS,IAAM,CACtD,IAAMC,EAAW,MAAMD,GAAU,OAAO,EACxC,GAAI,CAACC,GAAU,QAAU,CAACD,EAAS,YACjC,MAAM,IAAI,MAAM,kBAAkB,EAGpC,MAAO,CAAE,SAAUC,GAAY,CAAC,EAAG,QAASN,EAAS,QAAS,CAChE,EAPgC,WASnBO,EAAuBH,EAAA,CAAC,CAAE,SAAAC,EAAU,MAAAG,EAAO,eAAAC,CAAe,IAAM,CAC3EJ,GAAU,GAAG,kBAAoBC,GAAkB,CAC7CE,EAAM,WACJH,GACFI,EAAe,CAACH,CAAQ,EAAGN,EAAS,QAAQ,CAGlD,CAAC,CACH,EARoC,aAUvBU,EAAuCN,EAAA,IAAM,GAAN,sBAEvCO,EAA+CA,EAE/CC,EAAmCR,EAAA,CAAC,CAAE,SAAAC,CAAS,IAC1DA,EAAS,gBAAgB,EADqB,mBAGnCQ,EAAkET,EAC7EU,GACG,CACH,IAAMC,EAAWC,EAAmBF,CAAc,EAClD,MAAO,CACL,KAAM,UACN,IAAK,qGACL,YAAa,CACX,OACE,kGACF,MACE,kGACF,QAAS,iEACT,KAAM,oGACN,QAAS,sBACX,EAEA,MAAO,UACP,gBAAiBC,CACnB,CACF,EApB+E",
6
+ "names": ["WalletTypes", "Networks", "starknetBlockchain", "getBraavosInstance", "starknet_braavos", "__name", "DefaultStarknetSigner", "DefaultSignerFactory", "TxType", "getSigners", "provider", "signers", "DefaultSignerFactory", "TxType", "DefaultStarknetSigner", "__name", "WALLET", "WalletTypes", "config", "Networks", "getInstance", "getBraavosInstance", "connect", "__name", "instance", "accounts", "subscribe", "state", "updateAccounts", "canSwitchNetworkTo", "getSigners", "canEagerConnect", "getWalletInfo", "allBlockChains", "starknet", "starknetBlockchain"]
7
+ }
@@ -0,0 +1,3 @@
1
+ import { SignerFactory } from 'rango-types';
2
+ export default function getSigners(provider: any): SignerFactory;
3
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,aAAa,CAI/D"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@rango-dev/provider-braavos",
3
+ "version": "0.1.1-next.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "module": "./dist/index.js",
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-braavos",
18
+ "clean": "rimraf dist",
19
+ "format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
20
+ "lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
21
+ },
22
+ "dependencies": {
23
+ "@rango-dev/signer-starknet": "^0.5.1-next.4",
24
+ "@rango-dev/wallets-shared": "^0.8.0",
25
+ "rango-types": "^0.1.45"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ }
30
+ }
package/readme.md ADDED
@@ -0,0 +1 @@
1
+ # @rango-dev/provider-braavos
package/src/helpers.ts ADDED
@@ -0,0 +1,5 @@
1
+ export function getBraavosInstance() {
2
+ const { starknet_braavos } = window;
3
+ if (!!starknet_braavos) return starknet_braavos;
4
+ return null;
5
+ }
package/src/index.ts ADDED
@@ -0,0 +1,69 @@
1
+ import {
2
+ WalletTypes,
3
+ CanSwitchNetwork,
4
+ Connect,
5
+ Subscribe,
6
+ WalletInfo,
7
+ Networks,
8
+ CanEagerConnect,
9
+ } from '@rango-dev/wallets-shared';
10
+ import { SignerFactory, BlockchainMeta, starknetBlockchain } from 'rango-types';
11
+ import { getBraavosInstance } from './helpers';
12
+ import signer from './signer';
13
+
14
+ const WALLET = WalletTypes.BRAAVOS;
15
+
16
+ export const config = {
17
+ type: WALLET,
18
+ defaultNetwork: Networks.STARKNET,
19
+ };
20
+
21
+ export const getInstance = getBraavosInstance;
22
+
23
+ export const connect: Connect = async ({ instance }) => {
24
+ const accounts = await instance?.enable();
25
+ if (!accounts?.length || !instance.isConnected) {
26
+ throw new Error('Connection Error');
27
+ }
28
+
29
+ return { accounts: accounts || [], chainId: Networks.STARKNET };
30
+ };
31
+
32
+ export const subscribe: Subscribe = ({ instance, state, updateAccounts }) => {
33
+ instance?.on('accountsChanged', (accounts: any) => {
34
+ if (state.connected) {
35
+ if (instance) {
36
+ updateAccounts([accounts], Networks.STARKNET);
37
+ }
38
+ }
39
+ });
40
+ };
41
+
42
+ export const canSwitchNetworkTo: CanSwitchNetwork = () => false;
43
+
44
+ export const getSigners: (provider: any) => SignerFactory = signer;
45
+
46
+ export const canEagerConnect: CanEagerConnect = ({ instance }) =>
47
+ instance.isPreauthorized();
48
+
49
+ export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
50
+ allBlockChains
51
+ ) => {
52
+ const starknet = starknetBlockchain(allBlockChains);
53
+ return {
54
+ name: 'Braavos',
55
+ img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/braavos.png',
56
+ installLink: {
57
+ CHROME:
58
+ 'https://chrome.google.com/webstore/detail/braavos-smart-wallet/jnlgamecbpmbajjfhmmmlhejkemejdma',
59
+ BRAVE:
60
+ 'https://chrome.google.com/webstore/detail/braavos-smart-wallet/jnlgamecbpmbajjfhmmmlhejkemejdma',
61
+ FIREFOX: 'https://addons.mozilla.org/en-US/firefox/addon/braavos-wallet/',
62
+ EDGE: 'https://microsoftedge.microsoft.com/addons/detail/braavos-wallet/hkkpjehhcnhgefhbdcgfkeegglpjchdc',
63
+ DEFAULT: 'https://braavos.app/',
64
+ },
65
+
66
+ color: '#96e7ed',
67
+ supportedChains: starknet,
68
+ };
69
+ };
package/src/signer.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { DefaultStarknetSigner } from '@rango-dev/signer-starknet';
2
+ import {
3
+ DefaultSignerFactory,
4
+ SignerFactory,
5
+ TransactionType as TxType,
6
+ } from 'rango-types';
7
+
8
+ export default function getSigners(provider: any): SignerFactory {
9
+ const signers = new DefaultSignerFactory();
10
+ signers.registerSigner(TxType.STARKNET, new DefaultStarknetSigner(provider));
11
+ return signers;
12
+ }