@tcswap/wallet-core 4.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,4 @@
1
+ var{defineProperty:p,getOwnPropertyNames:r,getOwnPropertyDescriptor:i}=Object,d=Object.prototype.hasOwnProperty;var o=new WeakMap,y=(e)=>{var n=o.get(e),t;if(n)return n;if(n=p({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")r(e).map((a)=>!d.call(n,a)&&p(n,a,{get:()=>e[a],enumerable:!(t=i(e,a))||t.enumerable}));return o.set(e,n),n};var c=(e,n)=>{for(var t in n)p(e,t,{get:n[t],enumerable:!0,configurable:!0,set:(a)=>n[t]=()=>a})};var u={};c(u,{getWalletSupportedChains:()=>h,createWallet:()=>C});module.exports=y(u);function C({connect:e,name:n,supportedChains:t,walletType:a}){function s(l){return e({...l,supportedChains:t,walletType:a})}return{[n]:{connectWallet:s,supportedChains:t}}}function h(e){let n=Object.keys(e)?.[0]||"";return e?.[n]?.supportedChains||[]}
2
+
3
+ //# debugId=42E09D1F4154302B64756E2164756E21
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": [
5
+ "import type { AddChainType, Chain, WalletOption } from \"@tcswap/helpers\";\n\nexport function createWallet<\n ConnectParams extends any[],\n SupportedChains extends Chain[],\n const Name extends string,\n WalletType extends WalletOption,\n>({\n connect,\n name,\n supportedChains,\n walletType,\n}: {\n connect: (connectParams: {\n addChain: AddChainType;\n walletType: WalletType;\n supportedChains: SupportedChains;\n }) => (...params: ConnectParams) => Promise<boolean>;\n name: Name;\n supportedChains: SupportedChains;\n walletType?: WalletType | string;\n}) {\n function connectWallet(connectParams: { addChain: AddChainType }) {\n return connect({ ...connectParams, supportedChains, walletType: walletType as WalletType });\n }\n\n return { [name]: { connectWallet, supportedChains } } as unknown as {\n [key in Name]: { connectWallet: typeof connectWallet; supportedChains: SupportedChains };\n };\n}\n\nexport function getWalletSupportedChains<T extends ReturnType<typeof createWallet<any, any, any, any>>>(\n wallet: T,\n): T[keyof T][\"supportedChains\"] {\n const walletName = Object.keys(wallet)?.[0] || \"\";\n return wallet?.[walletName]?.supportedChains || [];\n}\n"
6
+ ],
7
+ "mappings": "+hBAEO,SAAS,CAKf,EACC,UACA,OACA,kBACA,cAUC,CACD,SAAS,CAAa,CAAC,EAA2C,CAChE,OAAO,EAAQ,IAAK,EAAe,kBAAiB,WAAY,CAAyB,CAAC,EAG5F,MAAO,EAAG,GAAO,CAAE,gBAAe,iBAAgB,CAAE,EAK/C,SAAS,CAAuF,CACrG,EAC+B,CAC/B,IAAM,EAAa,OAAO,KAAK,CAAM,IAAI,IAAM,GAC/C,OAAO,IAAS,IAAa,iBAAmB,CAAC",
8
+ "debugId": "42E09D1F4154302B64756E2164756E21",
9
+ "names": []
10
+ }
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ function s({connect:e,name:n,supportedChains:t,walletType:a}){function p(o){return e({...o,supportedChains:t,walletType:a})}return{[n]:{connectWallet:p,supportedChains:t}}}function l(e){let n=Object.keys(e)?.[0]||"";return e?.[n]?.supportedChains||[]}export{l as getWalletSupportedChains,s as createWallet};
2
+
3
+ //# debugId=4297ED4C32249A3164756E2164756E21
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": [
5
+ "import type { AddChainType, Chain, WalletOption } from \"@tcswap/helpers\";\n\nexport function createWallet<\n ConnectParams extends any[],\n SupportedChains extends Chain[],\n const Name extends string,\n WalletType extends WalletOption,\n>({\n connect,\n name,\n supportedChains,\n walletType,\n}: {\n connect: (connectParams: {\n addChain: AddChainType;\n walletType: WalletType;\n supportedChains: SupportedChains;\n }) => (...params: ConnectParams) => Promise<boolean>;\n name: Name;\n supportedChains: SupportedChains;\n walletType?: WalletType | string;\n}) {\n function connectWallet(connectParams: { addChain: AddChainType }) {\n return connect({ ...connectParams, supportedChains, walletType: walletType as WalletType });\n }\n\n return { [name]: { connectWallet, supportedChains } } as unknown as {\n [key in Name]: { connectWallet: typeof connectWallet; supportedChains: SupportedChains };\n };\n}\n\nexport function getWalletSupportedChains<T extends ReturnType<typeof createWallet<any, any, any, any>>>(\n wallet: T,\n): T[keyof T][\"supportedChains\"] {\n const walletName = Object.keys(wallet)?.[0] || \"\";\n return wallet?.[walletName]?.supportedChains || [];\n}\n"
6
+ ],
7
+ "mappings": "AAEO,SAAS,CAKf,EACC,UACA,OACA,kBACA,cAUC,CACD,SAAS,CAAa,CAAC,EAA2C,CAChE,OAAO,EAAQ,IAAK,EAAe,kBAAiB,WAAY,CAAyB,CAAC,EAG5F,MAAO,EAAG,GAAO,CAAE,gBAAe,iBAAgB,CAAE,EAK/C,SAAS,CAAuF,CACrG,EAC+B,CAC/B,IAAM,EAAa,OAAO,KAAK,CAAM,IAAI,IAAM,GAC/C,OAAO,IAAS,IAAa,iBAAmB,CAAC",
8
+ "debugId": "4297ED4C32249A3164756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,18 @@
1
+ import type { AddChainType, Chain, WalletOption } from "@tcswap/helpers";
2
+ export declare function createWallet<ConnectParams extends any[], SupportedChains extends Chain[], const Name extends string, WalletType extends WalletOption>({ connect, name, supportedChains, walletType, }: {
3
+ connect: (connectParams: {
4
+ addChain: AddChainType;
5
+ walletType: WalletType;
6
+ supportedChains: SupportedChains;
7
+ }) => (...params: ConnectParams) => Promise<boolean>;
8
+ name: Name;
9
+ supportedChains: SupportedChains;
10
+ walletType?: WalletType | string;
11
+ }): { [key in Name]: {
12
+ connectWallet: (connectParams: {
13
+ addChain: AddChainType;
14
+ }) => (...params: ConnectParams) => Promise<boolean>;
15
+ supportedChains: SupportedChains;
16
+ }; };
17
+ export declare function getWalletSupportedChains<T extends ReturnType<typeof createWallet<any, any, any, any>>>(wallet: T): T[keyof T]["supportedChains"];
18
+ //# 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,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzE,wBAAgB,YAAY,CAC1B,aAAa,SAAS,GAAG,EAAE,EAC3B,eAAe,SAAS,KAAK,EAAE,EAC/B,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,UAAU,SAAS,YAAY,EAC/B,EACA,OAAO,EACP,IAAI,EACJ,eAAe,EACf,UAAU,GACX,EAAE;IACD,OAAO,EAAE,CAAC,aAAa,EAAE;QACvB,QAAQ,EAAE,YAAY,CAAC;QACvB,UAAU,EAAE,UAAU,CAAC;QACvB,eAAe,EAAE,eAAe,CAAC;KAClC,KAAK,CAAC,GAAG,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,IAAI,EAAE,IAAI,CAAC;IACX,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC,GAKqE,GACjE,GAAG,IAAI,IAAI,GAAG;IAAE,aAAa,kBALM;QAAE,QAAQ,EAAE,YAAY,CAAA;KAAE,iBAL9C,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAUG;IAAC,eAAe,EAAE,eAAe,CAAA;CAAE,GACzF,CACF;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EACpG,MAAM,EAAE,CAAC,GACR,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAG/B"}
@@ -0,0 +1,10 @@
1
+ import type { AddChainType, Chain, WalletOption } from "@tcswap/helpers";
2
+ export type ConnectFunction<ConnectParams extends any[], SupportedChains extends Chain[], WalletType extends WalletOption> = (connectParams: {
3
+ addChain: AddChainType;
4
+ walletType: WalletType;
5
+ supportedChains: SupportedChains;
6
+ }) => (...params: ConnectParams) => Promise<boolean>;
7
+ export type CreateFunction<CreateParams extends any[], WalletType extends WalletOption, Wallets extends Record<Chain, any>> = (createParams: {
8
+ walletType: WalletType;
9
+ }) => (...params: CreateParams) => Promise<Wallets> | Wallets;
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzE,MAAM,MAAM,eAAe,CACzB,aAAa,SAAS,GAAG,EAAE,EAC3B,eAAe,SAAS,KAAK,EAAE,EAC/B,UAAU,SAAS,YAAY,IAC7B,CAAC,aAAa,EAAE;IAClB,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;CAClC,KAAK,CAAC,GAAG,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAErD,MAAM,MAAM,cAAc,CACxB,YAAY,SAAS,GAAG,EAAE,EAC1B,UAAU,SAAS,YAAY,EAC/B,OAAO,SAAS,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAChC,CAAC,YAAY,EAAE;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,KAAK,CAAC,GAAG,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "author": "swapkit-oss",
3
+ "dependencies": { "@tcswap/helpers": "4.5.15" },
4
+ "description": "USwap - Wallet Core",
5
+ "exports": {
6
+ ".": {
7
+ "bun": "./src/index.ts",
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.cjs",
10
+ "types": "./dist/types/index.d.ts"
11
+ }
12
+ },
13
+ "files": ["dist/", "src/"],
14
+ "homepage": "https://github.com/thorchain/TCSwap",
15
+ "license": "Apache-2.0",
16
+ "name": "@tcswap/wallet-core",
17
+ "repository": {
18
+ "directory": "packages/wallet-core",
19
+ "type": "git",
20
+ "url": "git+https://github.com/thorchain/TCSwap.git"
21
+ },
22
+ "scripts": {
23
+ "build": "bun run ./build.ts",
24
+ "build:clean": "rm -rf dist && bun run ./build.ts",
25
+ "clean": "rm -rf dist node_modules *.tsbuildinfo",
26
+ "test": "echo 'bun test'",
27
+ "test:ci": "echo 'bun test --coverage'",
28
+ "type-check": "bun tsc --noEmit",
29
+ "type-check:go": "tsgo"
30
+ },
31
+ "type": "module",
32
+ "version": "4.0.59"
33
+ }
package/src/index.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { AddChainType, Chain, WalletOption } from "@tcswap/helpers";
2
+
3
+ export function createWallet<
4
+ ConnectParams extends any[],
5
+ SupportedChains extends Chain[],
6
+ const Name extends string,
7
+ WalletType extends WalletOption,
8
+ >({
9
+ connect,
10
+ name,
11
+ supportedChains,
12
+ walletType,
13
+ }: {
14
+ connect: (connectParams: {
15
+ addChain: AddChainType;
16
+ walletType: WalletType;
17
+ supportedChains: SupportedChains;
18
+ }) => (...params: ConnectParams) => Promise<boolean>;
19
+ name: Name;
20
+ supportedChains: SupportedChains;
21
+ walletType?: WalletType | string;
22
+ }) {
23
+ function connectWallet(connectParams: { addChain: AddChainType }) {
24
+ return connect({ ...connectParams, supportedChains, walletType: walletType as WalletType });
25
+ }
26
+
27
+ return { [name]: { connectWallet, supportedChains } } as unknown as {
28
+ [key in Name]: { connectWallet: typeof connectWallet; supportedChains: SupportedChains };
29
+ };
30
+ }
31
+
32
+ export function getWalletSupportedChains<T extends ReturnType<typeof createWallet<any, any, any, any>>>(
33
+ wallet: T,
34
+ ): T[keyof T]["supportedChains"] {
35
+ const walletName = Object.keys(wallet)?.[0] || "";
36
+ return wallet?.[walletName]?.supportedChains || [];
37
+ }
package/src/types.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { AddChainType, Chain, WalletOption } from "@tcswap/helpers";
2
+
3
+ export type ConnectFunction<
4
+ ConnectParams extends any[],
5
+ SupportedChains extends Chain[],
6
+ WalletType extends WalletOption,
7
+ > = (connectParams: {
8
+ addChain: AddChainType;
9
+ walletType: WalletType;
10
+ supportedChains: SupportedChains;
11
+ }) => (...params: ConnectParams) => Promise<boolean>;
12
+
13
+ export type CreateFunction<
14
+ CreateParams extends any[],
15
+ WalletType extends WalletOption,
16
+ Wallets extends Record<Chain, any>,
17
+ > = (createParams: { walletType: WalletType }) => (...params: CreateParams) => Promise<Wallets> | Wallets;