@multiplatform.one/web3 7.25.0 → 7.26.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/dist/cjs/core/family.cjs +88 -0
- package/dist/cjs/core/family.native.js +115 -0
- package/dist/cjs/core/family.native.js.map +1 -0
- package/dist/cjs/core/index.cjs +41 -0
- package/dist/cjs/core/index.native.js +44 -0
- package/dist/cjs/core/index.native.js.map +1 -0
- package/dist/cjs/core/message.cjs +89 -0
- package/dist/cjs/core/message.native.js +104 -0
- package/dist/cjs/core/message.native.js.map +1 -0
- package/dist/cjs/core/names.cjs +51 -0
- package/dist/cjs/core/names.native.js +95 -0
- package/dist/cjs/core/names.native.js.map +1 -0
- package/dist/cjs/core/react.cjs +48 -0
- package/dist/cjs/core/react.native.js +52 -0
- package/dist/cjs/core/react.native.js.map +1 -0
- package/dist/cjs/core/store.cjs +450 -0
- package/dist/cjs/core/store.native.js +637 -0
- package/dist/cjs/core/store.native.js.map +1 -0
- package/dist/cjs/core/types.cjs +18 -0
- package/dist/cjs/core/types.native.js +21 -0
- package/dist/cjs/core/types.native.js.map +1 -0
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.native.js +1 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/core/family.mjs +62 -0
- package/dist/esm/core/family.mjs.map +1 -0
- package/dist/esm/core/family.native.js +86 -0
- package/dist/esm/core/family.native.js.map +1 -0
- package/dist/esm/core/index.mjs +7 -0
- package/dist/esm/core/index.mjs.map +1 -0
- package/dist/esm/core/index.native.js +7 -0
- package/dist/esm/core/index.native.js.map +1 -0
- package/dist/esm/core/message.mjs +63 -0
- package/dist/esm/core/message.mjs.map +1 -0
- package/dist/esm/core/message.native.js +75 -0
- package/dist/esm/core/message.native.js.map +1 -0
- package/dist/esm/core/names.mjs +25 -0
- package/dist/esm/core/names.mjs.map +1 -0
- package/dist/esm/core/names.native.js +66 -0
- package/dist/esm/core/names.native.js.map +1 -0
- package/dist/esm/core/react.mjs +21 -0
- package/dist/esm/core/react.mjs.map +1 -0
- package/dist/esm/core/react.native.js +22 -0
- package/dist/esm/core/react.native.js.map +1 -0
- package/dist/esm/core/store.mjs +424 -0
- package/dist/esm/core/store.mjs.map +1 -0
- package/dist/esm/core/store.native.js +608 -0
- package/dist/esm/core/store.native.js.map +1 -0
- package/dist/esm/core/types.mjs +2 -0
- package/dist/esm/core/types.mjs.map +1 -0
- package/dist/esm/core/types.native.js +2 -0
- package/dist/esm/core/types.native.js.map +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/core/family.mjs +62 -0
- package/dist/jsx/core/family.mjs.map +1 -0
- package/dist/jsx/core/family.native.js +115 -0
- package/dist/jsx/core/family.native.js.map +1 -0
- package/dist/jsx/core/index.mjs +7 -0
- package/dist/jsx/core/index.mjs.map +1 -0
- package/dist/jsx/core/index.native.js +44 -0
- package/dist/jsx/core/index.native.js.map +1 -0
- package/dist/jsx/core/message.mjs +63 -0
- package/dist/jsx/core/message.mjs.map +1 -0
- package/dist/jsx/core/message.native.js +104 -0
- package/dist/jsx/core/message.native.js.map +1 -0
- package/dist/jsx/core/names.mjs +25 -0
- package/dist/jsx/core/names.mjs.map +1 -0
- package/dist/jsx/core/names.native.js +95 -0
- package/dist/jsx/core/names.native.js.map +1 -0
- package/dist/jsx/core/react.mjs +21 -0
- package/dist/jsx/core/react.mjs.map +1 -0
- package/dist/jsx/core/react.native.js +52 -0
- package/dist/jsx/core/react.native.js.map +1 -0
- package/dist/jsx/core/store.mjs +424 -0
- package/dist/jsx/core/store.mjs.map +1 -0
- package/dist/jsx/core/store.native.js +637 -0
- package/dist/jsx/core/store.native.js.map +1 -0
- package/dist/jsx/core/types.mjs +2 -0
- package/dist/jsx/core/types.mjs.map +1 -0
- package/dist/jsx/core/types.native.js +21 -0
- package/dist/jsx/core/types.native.js.map +1 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -0
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +1 -0
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +6 -6
- package/src/core/family.spec.ts +117 -0
- package/src/core/family.ts +103 -0
- package/src/core/imports.spec.ts +82 -0
- package/src/core/index.ts +47 -0
- package/src/core/message.spec.ts +178 -0
- package/src/core/message.ts +119 -0
- package/src/core/names.ts +29 -0
- package/src/core/react.spec.tsx +75 -0
- package/src/core/react.ts +34 -0
- package/src/core/store.spec.ts +890 -0
- package/src/core/store.ts +558 -0
- package/src/core/types.ts +96 -0
- package/src/index.ts +4 -0
- package/types/core/family.d.ts +44 -0
- package/types/core/family.d.ts.map +1 -0
- package/types/core/index.d.ts +7 -0
- package/types/core/index.d.ts.map +1 -0
- package/types/core/message.d.ts +44 -0
- package/types/core/message.d.ts.map +1 -0
- package/types/core/names.d.ts +7 -0
- package/types/core/names.d.ts.map +1 -0
- package/types/core/react.d.ts +14 -0
- package/types/core/react.d.ts.map +1 -0
- package/types/core/store.d.ts +64 -0
- package/types/core/store.d.ts.map +1 -0
- package/types/core/types.d.ts +88 -0
- package/types/core/types.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
}), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
module.exports = __toCommonJS(types_exports);
|
|
21
|
+
//# sourceMappingURL=types.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":[],"sourcesContent":[],"mappings":"","ignoreList":[]}
|
package/dist/jsx/index.js
CHANGED
|
@@ -6,5 +6,6 @@ import { mainnet, polygon, optimism, arbitrum, base, sepolia } from "wagmi/chain
|
|
|
6
6
|
export * from "./bridge/index.mjs";
|
|
7
7
|
export * from "./message/index.mjs";
|
|
8
8
|
export * from "./clients/index.mjs";
|
|
9
|
+
export * from "./core/index.mjs";
|
|
9
10
|
export { ConnectKitButton, LockContract, NetworkSwitcher, TransactionStatus as TransactionStatusComponent, WalletAvatar, WalletButton, WalletProvider, WalletStatus, arbitrum, base, defaultChains, lockAbi, mainnet, optimism, polygon, sepolia, useAccount, useBalance, useBlockNumber, useChainId, useChains, useConnect, useContractRead, useContractWrite, useDisconnect, useEnsAvatar, useEnsName, useReadContract, useSignMessage, useSimulateContract, useSwitchChain, useWaitForTransactionReceipt, useWallet, useWalletBridge, useWeb3Config, useWriteContract };
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/dist/jsx/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WalletProvider","useWeb3Config","defaultChains","useWalletBridge","useWallet","useContractRead","useContractWrite","useAccount","useBalance","useChainId","useChains","useConnect","useDisconnect","useEnsAvatar","useEnsName","useSignMessage","useSwitchChain","useBlockNumber","useReadContract","useWriteContract","useSimulateContract","useWaitForTransactionReceipt","WalletButton","WalletAvatar","WalletStatus","NetworkSwitcher","TransactionStatus","ConnectKitButton","LockContract","lockAbi","mainnet","polygon","optimism","arbitrum","base","sepolia"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA,SACEA,cAAA,EACAC,aAAA,EACAC,aAAA,EACAC,eAAA,QAIK;AAGP,SACEC,SAAA,EAKAC,eAAA,EACAC,gBAAA,EAOAC,UAAA,EACAC,UAAA,EACAC,UAAA,EACAC,SAAA,EACAC,UAAA,EACAC,aAAA,EACAC,YAAA,EACAC,UAAA,EACAC,cAAA,EACAC,cAAA,EACAC,cAAA,EACAC,eAAA,EACAC,gBAAA,EACAC,mBAAA,EACAC,4BAAA,QACK;AAGP,SACEC,YAAA,EACAC,YAAA,EACAC,YAAA,EACAC,eAAA,EACqBC,iBAAA,EACrBC,gBAAA,QAMK;AAGP,SAASC,YAAA,EAAcC,OAAA,QAAuC;AAI9D,SAASC,OAAA,EAASC,OAAA,EAASC,QAAA,EAAUC,QAAA,EAAUC,IAAA,EAAMC,OAAA,QAAe;AAGpE,cAAc;AAGd,cAAc;AAId,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["WalletProvider","useWeb3Config","defaultChains","useWalletBridge","useWallet","useContractRead","useContractWrite","useAccount","useBalance","useChainId","useChains","useConnect","useDisconnect","useEnsAvatar","useEnsName","useSignMessage","useSwitchChain","useBlockNumber","useReadContract","useWriteContract","useSimulateContract","useWaitForTransactionReceipt","WalletButton","WalletAvatar","WalletStatus","NetworkSwitcher","TransactionStatus","ConnectKitButton","LockContract","lockAbi","mainnet","polygon","optimism","arbitrum","base","sepolia"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA,SACEA,cAAA,EACAC,aAAA,EACAC,aAAA,EACAC,eAAA,QAIK;AAGP,SACEC,SAAA,EAKAC,eAAA,EACAC,gBAAA,EAOAC,UAAA,EACAC,UAAA,EACAC,UAAA,EACAC,SAAA,EACAC,UAAA,EACAC,aAAA,EACAC,YAAA,EACAC,UAAA,EACAC,cAAA,EACAC,cAAA,EACAC,cAAA,EACAC,eAAA,EACAC,gBAAA,EACAC,mBAAA,EACAC,4BAAA,QACK;AAGP,SACEC,YAAA,EACAC,YAAA,EACAC,YAAA,EACAC,eAAA,EACqBC,iBAAA,EACrBC,gBAAA,QAMK;AAGP,SAASC,YAAA,EAAcC,OAAA,QAAuC;AAI9D,SAASC,OAAA,EAASC,OAAA,EAASC,QAAA,EAAUC,QAAA,EAAUC,IAAA,EAAMC,OAAA,QAAe;AAGpE,cAAc;AAGd,cAAc;AAId,cAAc;AASd,cAAc","ignoreList":[]}
|
package/dist/jsx/index.mjs
CHANGED
|
@@ -6,5 +6,6 @@ import { mainnet, polygon, optimism, arbitrum, base, sepolia } from "wagmi/chain
|
|
|
6
6
|
export * from "./bridge/index.mjs";
|
|
7
7
|
export * from "./message/index.mjs";
|
|
8
8
|
export * from "./clients/index.mjs";
|
|
9
|
+
export * from "./core/index.mjs";
|
|
9
10
|
export { ConnectKitButton, LockContract, NetworkSwitcher, TransactionStatus as TransactionStatusComponent, WalletAvatar, WalletButton, WalletProvider, WalletStatus, arbitrum, base, defaultChains, lockAbi, mainnet, optimism, polygon, sepolia, useAccount, useBalance, useBlockNumber, useChainId, useChains, useConnect, useContractRead, useContractWrite, useDisconnect, useEnsAvatar, useEnsName, useReadContract, useSignMessage, useSimulateContract, useSwitchChain, useWaitForTransactionReceipt, useWallet, useWalletBridge, useWeb3Config, useWriteContract };
|
|
10
11
|
//# sourceMappingURL=index.mjs.map
|
package/dist/jsx/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WalletProvider","useWeb3Config","defaultChains","useWalletBridge","useWallet","useContractRead","useContractWrite","useAccount","useBalance","useChainId","useChains","useConnect","useDisconnect","useEnsAvatar","useEnsName","useSignMessage","useSwitchChain","useBlockNumber","useReadContract","useWriteContract","useSimulateContract","useWaitForTransactionReceipt","WalletButton","WalletAvatar","WalletStatus","NetworkSwitcher","TransactionStatus","ConnectKitButton","LockContract","lockAbi","mainnet","polygon","optimism","arbitrum","base","sepolia"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA,SACEA,cAAA,EACAC,aAAA,EACAC,aAAA,EACAC,eAAA,QAIK;AAGP,SACEC,SAAA,EAKAC,eAAA,EACAC,gBAAA,EAOAC,UAAA,EACAC,UAAA,EACAC,UAAA,EACAC,SAAA,EACAC,UAAA,EACAC,aAAA,EACAC,YAAA,EACAC,UAAA,EACAC,cAAA,EACAC,cAAA,EACAC,cAAA,EACAC,eAAA,EACAC,gBAAA,EACAC,mBAAA,EACAC,4BAAA,QACK;AAGP,SACEC,YAAA,EACAC,YAAA,EACAC,YAAA,EACAC,eAAA,EACqBC,iBAAA,EACrBC,gBAAA,QAMK;AAGP,SAASC,YAAA,EAAcC,OAAA,QAAuC;AAI9D,SAASC,OAAA,EAASC,OAAA,EAASC,QAAA,EAAUC,QAAA,EAAUC,IAAA,EAAMC,OAAA,QAAe;AAGpE,cAAc;AAGd,cAAc;AAId,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["WalletProvider","useWeb3Config","defaultChains","useWalletBridge","useWallet","useContractRead","useContractWrite","useAccount","useBalance","useChainId","useChains","useConnect","useDisconnect","useEnsAvatar","useEnsName","useSignMessage","useSwitchChain","useBlockNumber","useReadContract","useWriteContract","useSimulateContract","useWaitForTransactionReceipt","WalletButton","WalletAvatar","WalletStatus","NetworkSwitcher","TransactionStatus","ConnectKitButton","LockContract","lockAbi","mainnet","polygon","optimism","arbitrum","base","sepolia"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA,SACEA,cAAA,EACAC,aAAA,EACAC,aAAA,EACAC,eAAA,QAIK;AAGP,SACEC,SAAA,EAKAC,eAAA,EACAC,gBAAA,EAOAC,UAAA,EACAC,UAAA,EACAC,UAAA,EACAC,SAAA,EACAC,UAAA,EACAC,aAAA,EACAC,YAAA,EACAC,UAAA,EACAC,cAAA,EACAC,cAAA,EACAC,cAAA,EACAC,eAAA,EACAC,gBAAA,EACAC,mBAAA,EACAC,4BAAA,QACK;AAGP,SACEC,YAAA,EACAC,YAAA,EACAC,YAAA,EACAC,eAAA,EACqBC,iBAAA,EACrBC,gBAAA,QAMK;AAGP,SAASC,YAAA,EAAcC,OAAA,QAAuC;AAI9D,SAASC,OAAA,EAASC,OAAA,EAASC,QAAA,EAAUC,QAAA,EAAUC,IAAA,EAAMC,OAAA,QAAe;AAGpE,cAAc;AAGd,cAAc;AAId,cAAc;AASd,cAAc","ignoreList":[]}
|
package/dist/jsx/index.native.js
CHANGED
|
@@ -71,4 +71,5 @@ var import_chains = require("wagmi/chains");
|
|
|
71
71
|
__reExport(index_exports, require("./bridge/index.native.js"), module.exports);
|
|
72
72
|
__reExport(index_exports, require("./message/index.native.js"), module.exports);
|
|
73
73
|
__reExport(index_exports, require("./clients/index.native.js"), module.exports);
|
|
74
|
+
__reExport(index_exports, require("./core/index.native.js"), module.exports);
|
|
74
75
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__reExport","mod","secondTarget","__toCommonJS","value","index_exports","ConnectKitButton","import_components","LockContract","import_examples","NetworkSwitcher","TransactionStatusComponent","TransactionStatus","WalletAvatar","WalletButton","WalletProvider","import_providers","WalletStatus","arbitrum","import_chains","base","defaultChains","lockAbi","mainnet","optimism","polygon","sepolia","useAccount","import_hooks","useBalance"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA;;AAAA,IACEA,SAAA,GAAAC,MAAA,CAAAC,cAAA;AAAA,IACAC,gBAAA,GAAAF,MAAA,CAAAG,wBAAA;AAAA,IACAC,iBAAA,GAAAJ,MAAA,CAAAK,mBAAA;AAAA,IACAC,YAAA,GAAAN,MAAA,CAAAO,SAAA,CAAAC,cAAA;AAAA,IAAAC,QAIK,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EAGP,SAAAC,IAAA,IAAAD,GAAA,EACEZ,SAAA,CAAAW,MAAA,EAAAE,IAAA;IAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAA;EAAA;AAAA;AAKA,IACAC,WAAA,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,IAAA;EAOA,IAAAF,IAAA,WAAAA,IAAA,wBAAAA,IAAA;IACA,SAAAG,GAAA,IAAAhB,iBAAA,CAAAa,IAAA,GACA,KAAAX,YAAA,CAAAe,IAAA,CAAAL,EAAA,EAAAI,GAAA,KAAAA,GAAA,KAAAF,MAAA,EACAnB,SAAA,CAAAiB,EAAA,EAAAI,GAAA;MAAAP,GAAA,EAAAA,CAAA,KAAAI,IAAA,CAAAG,GAAA;MAAAN,UAAA,IAAAK,IAAA,GAAAjB,gBAAA,CAAAe,IAAA,EAAAG,GAAA,MAAAD,IAAA,CAAAL;IAAA;EACA;EACA,OAAAE,EAAA;AAAA;AACA,IACAM,UAAA,GAAAA,CAAAZ,MAAA,EAAAa,GAAA,EAAAC,YAAA,MAAAT,WAAA,CAAAL,MAAA,EAAAa,GAAA,cAAAC,YAAA,IAAAT,WAAA,CAAAS,YAAA,EAAAD,GAAA;AAAA,IACAE,YAAA,GAAAF,GAAA,IAAAR,WAAA,CAAAhB,SAAA;EAAA2B,KAAA;AAAA,IAAAH,GAAA;AAAA,IACAI,aAAA;AAAAlB,QACA,CAAAkB,aAAA;EACAC,gBAAA,EAAAA,CAAA,KAAAC,iBAAA,CAAAD,gBAAA;EACAE,YAAA,EAAAA,CAAA,KAAAC,eAAA,CAAAD,YAAA;EACAE,eAAA,EAAAA,CAAA,KAAAH,iBAAA,CAAAG,eAAA;EACAC,0BAAA,EAAAA,CAAA,KAAAJ,iBAAA,CAAAK,iBAAA;EAAAC,YACK,EAAAA,CAAA,KAAAN,iBAAA,CAAAM,YAAA;EAGPC,YAAA,EAAAA,CAAA,KAAAP,iBAAA,CAAAO,YAAA;EACEC,cAAA,EAAAA,CAAA,KAAAC,gBAAA,CAAAD,cAAA;EACAE,YAAA,EAAAA,CAAA,KAAAV,iBAAA,CAAAU,YAAA;EACAC,QAAA,EAAAA,CAAA,KAAAC,aAAA,CAAAD,QAAA;EACAE,IAAA,EAAAA,CAAA,KAAAD,aAAA,CAAAC,IAAA;EACqBC,aAAA,EAAAA,CAAA,KAAAL,gBAAA,CAAAK,aAAA;EACrBC,OAAA,EAAAA,CAAA,KAAAb,eAAA,CAAAa,OAAA;EAAAC,OAMK,EAAAA,CAAA,KAAAJ,aAAA,CAAAI,OAAA;EAGPC,QAAS,EAAAA,CAAA,KAAAL,aAAc,CAAAK,QAAuC;EAI9DC,OAAS,EAAAA,CAAA,KAAAN,aAAkB,CAAAM,OAAU;EAGrCC,OAAA,EAAAA,CAAA,KAAcP,aAAA,CAAAO,OAAA;EAGdC,UAAA,EAAcA,CAAA,KAAAC,YAAA,CAAAD,UAAA;EAIdE,UAAA,EAAcA,CAAA,KAAAD,YAAA,CAAAC,UAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__reExport","mod","secondTarget","__toCommonJS","value","index_exports","ConnectKitButton","import_components","LockContract","import_examples","NetworkSwitcher","TransactionStatusComponent","TransactionStatus","WalletAvatar","WalletButton","WalletProvider","import_providers","WalletStatus","arbitrum","import_chains","base","defaultChains","lockAbi","mainnet","optimism","polygon","sepolia","useAccount","import_hooks","useBalance","useBlockNumber"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA;;AAAA,IACEA,SAAA,GAAAC,MAAA,CAAAC,cAAA;AAAA,IACAC,gBAAA,GAAAF,MAAA,CAAAG,wBAAA;AAAA,IACAC,iBAAA,GAAAJ,MAAA,CAAAK,mBAAA;AAAA,IACAC,YAAA,GAAAN,MAAA,CAAAO,SAAA,CAAAC,cAAA;AAAA,IAAAC,QAIK,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EAGP,SAAAC,IAAA,IAAAD,GAAA,EACEZ,SAAA,CAAAW,MAAA,EAAAE,IAAA;IAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAA;EAAA;AAAA;AAKA,IACAC,WAAA,GAAAA,CAAAC,EAAA,EAAAC,IAAA,EAAAC,MAAA,EAAAC,IAAA;EAOA,IAAAF,IAAA,WAAAA,IAAA,wBAAAA,IAAA;IACA,SAAAG,GAAA,IAAAhB,iBAAA,CAAAa,IAAA,GACA,KAAAX,YAAA,CAAAe,IAAA,CAAAL,EAAA,EAAAI,GAAA,KAAAA,GAAA,KAAAF,MAAA,EACAnB,SAAA,CAAAiB,EAAA,EAAAI,GAAA;MAAAP,GAAA,EAAAA,CAAA,KAAAI,IAAA,CAAAG,GAAA;MAAAN,UAAA,IAAAK,IAAA,GAAAjB,gBAAA,CAAAe,IAAA,EAAAG,GAAA,MAAAD,IAAA,CAAAL;IAAA;EACA;EACA,OAAAE,EAAA;AAAA;AACA,IACAM,UAAA,GAAAA,CAAAZ,MAAA,EAAAa,GAAA,EAAAC,YAAA,MAAAT,WAAA,CAAAL,MAAA,EAAAa,GAAA,cAAAC,YAAA,IAAAT,WAAA,CAAAS,YAAA,EAAAD,GAAA;AAAA,IACAE,YAAA,GAAAF,GAAA,IAAAR,WAAA,CAAAhB,SAAA;EAAA2B,KAAA;AAAA,IAAAH,GAAA;AAAA,IACAI,aAAA;AAAAlB,QACA,CAAAkB,aAAA;EACAC,gBAAA,EAAAA,CAAA,KAAAC,iBAAA,CAAAD,gBAAA;EACAE,YAAA,EAAAA,CAAA,KAAAC,eAAA,CAAAD,YAAA;EACAE,eAAA,EAAAA,CAAA,KAAAH,iBAAA,CAAAG,eAAA;EACAC,0BAAA,EAAAA,CAAA,KAAAJ,iBAAA,CAAAK,iBAAA;EAAAC,YACK,EAAAA,CAAA,KAAAN,iBAAA,CAAAM,YAAA;EAGPC,YAAA,EAAAA,CAAA,KAAAP,iBAAA,CAAAO,YAAA;EACEC,cAAA,EAAAA,CAAA,KAAAC,gBAAA,CAAAD,cAAA;EACAE,YAAA,EAAAA,CAAA,KAAAV,iBAAA,CAAAU,YAAA;EACAC,QAAA,EAAAA,CAAA,KAAAC,aAAA,CAAAD,QAAA;EACAE,IAAA,EAAAA,CAAA,KAAAD,aAAA,CAAAC,IAAA;EACqBC,aAAA,EAAAA,CAAA,KAAAL,gBAAA,CAAAK,aAAA;EACrBC,OAAA,EAAAA,CAAA,KAAAb,eAAA,CAAAa,OAAA;EAAAC,OAMK,EAAAA,CAAA,KAAAJ,aAAA,CAAAI,OAAA;EAGPC,QAAS,EAAAA,CAAA,KAAAL,aAAc,CAAAK,QAAuC;EAI9DC,OAAS,EAAAA,CAAA,KAAAN,aAAkB,CAAAM,OAAU;EAGrCC,OAAA,EAAAA,CAAA,KAAcP,aAAA,CAAAO,OAAA;EAGdC,UAAA,EAAcA,CAAA,KAAAC,YAAA,CAAAD,UAAA;EAIdE,UAAA,EAAcA,CAAA,KAAAD,YAAA,CAAAC,UAAA;EASdC,cAAc,EAAAA,CAAA,KAAAF,YAAA,CAAAE,cAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/web3",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.26.0",
|
|
4
4
|
"description": "Web3 wallet integration for multiplatform.one ecosystem with ConnectKit and wagmi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"connectkit",
|
|
@@ -107,10 +107,10 @@
|
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"@aave/account": "^0.2.0",
|
|
109
109
|
"@metamask/connect-evm": "^2.1.1",
|
|
110
|
-
"@multiplatform.one/connectkit": "7.
|
|
111
|
-
"@multiplatform.one/gpg": "7.
|
|
112
|
-
"@multiplatform.one/platform": "7.
|
|
113
|
-
"@multiplatform.one/theme": "7.
|
|
110
|
+
"@multiplatform.one/connectkit": "7.26.0",
|
|
111
|
+
"@multiplatform.one/gpg": "7.26.0",
|
|
112
|
+
"@multiplatform.one/platform": "7.26.0",
|
|
113
|
+
"@multiplatform.one/theme": "7.26.0",
|
|
114
114
|
"@noble/curves": "^1.9.7",
|
|
115
115
|
"@solana/kit": "^8.3.0",
|
|
116
116
|
"@solana/wallet-adapter-base": "^0.9.27",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"wagmi": "^3.7.1"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
|
-
"@multiplatform.one/config": "7.
|
|
137
|
+
"@multiplatform.one/config": "7.26.0",
|
|
138
138
|
"@tamagui/build": "2.7.6",
|
|
139
139
|
"@tanstack/react-query": "^5.100.7",
|
|
140
140
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { testDriver } from "../../tests/core/testDriver";
|
|
3
|
+
import { createFamilyRegistry, defineWalletFamily, type WalletFamilyDefinition } from "./family";
|
|
4
|
+
|
|
5
|
+
const message = {
|
|
6
|
+
header: "wants you to sign in with your Solana account:",
|
|
7
|
+
statement: null,
|
|
8
|
+
chainId: "solana:mainnet",
|
|
9
|
+
};
|
|
10
|
+
const driver = () => testDriver("solana", [], {});
|
|
11
|
+
const sol: WalletFamilyDefinition = {
|
|
12
|
+
id: "sol",
|
|
13
|
+
label: "Solana",
|
|
14
|
+
aliases: ["solana"],
|
|
15
|
+
message,
|
|
16
|
+
driver,
|
|
17
|
+
};
|
|
18
|
+
const gpg: WalletFamilyDefinition = {
|
|
19
|
+
id: "gpg",
|
|
20
|
+
label: "GPG",
|
|
21
|
+
message: {
|
|
22
|
+
header: "wants you to sign in with your GPG key.",
|
|
23
|
+
statement: null,
|
|
24
|
+
chainId: null,
|
|
25
|
+
address: false,
|
|
26
|
+
},
|
|
27
|
+
connectionless: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe("defineWalletFamily", () => {
|
|
31
|
+
it("returns a frozen family with defaults filled in", () => {
|
|
32
|
+
const family = defineWalletFamily({ id: "sui", label: "Sui", message, driver });
|
|
33
|
+
expect(family).toMatchObject({ id: "sui", label: "Sui", aliases: [], connectionless: false });
|
|
34
|
+
expect(Object.isFrozen(family)).toBe(true);
|
|
35
|
+
expect(Object.isFrozen(family.aliases)).toBe(true);
|
|
36
|
+
expect(Object.isFrozen(family.message)).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("does not share the caller's arrays", () => {
|
|
40
|
+
const aliases = ["solana"];
|
|
41
|
+
const family = defineWalletFamily({ ...sol, aliases });
|
|
42
|
+
aliases.push("other");
|
|
43
|
+
expect(family.aliases).toEqual(["solana"]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("a connectionless family has no driver", () => {
|
|
47
|
+
expect(defineWalletFamily(gpg).connectionless).toBe(true);
|
|
48
|
+
expect(() => defineWalletFamily({ ...gpg, driver })).toThrow(
|
|
49
|
+
/connectionless.*cannot have a driver/,
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("a connectable family needs a driver", () => {
|
|
54
|
+
expect(() => defineWalletFamily({ ...sol, driver: undefined })).toThrow(/needs a driver/);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it.each([
|
|
58
|
+
[{ id: "Sol" }, /id must be lowercase/],
|
|
59
|
+
[{ id: "" }, /id must be lowercase/],
|
|
60
|
+
[{ id: "9sol" }, /id must be lowercase/],
|
|
61
|
+
[{ aliases: ["Solana"] }, /alias must be lowercase/],
|
|
62
|
+
[{ aliases: ["sol"] }, /its own id as an alias/],
|
|
63
|
+
[{ label: " " }, /needs a label/],
|
|
64
|
+
[{ message: { ...message, header: "" } }, /message spec with a header/],
|
|
65
|
+
])("refuses %o", (change, error) => {
|
|
66
|
+
expect(() => defineWalletFamily({ ...sol, ...change } as WalletFamilyDefinition)).toThrow(
|
|
67
|
+
error,
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe("createFamilyRegistry", () => {
|
|
73
|
+
const registry = createFamilyRegistry([defineWalletFamily(sol), defineWalletFamily(gpg)]);
|
|
74
|
+
|
|
75
|
+
it("finds a family by id or alias, in the order the app listed them", () => {
|
|
76
|
+
expect(registry.families.map((family) => family.id)).toEqual(["sol", "gpg"]);
|
|
77
|
+
expect(registry.get("sol")?.label).toBe("Solana");
|
|
78
|
+
expect(registry.get("solana")?.id).toBe("sol");
|
|
79
|
+
expect(registry.get("eth")).toBeUndefined();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("require names the registered families when one is missing", () => {
|
|
83
|
+
expect(registry.require("solana").id).toBe("sol");
|
|
84
|
+
expect(() => registry.require("eth")).toThrow(
|
|
85
|
+
"wallet family eth is not registered; registered: sol, gpg",
|
|
86
|
+
);
|
|
87
|
+
expect(() => createFamilyRegistry([]).require("eth")).toThrow(/registered: none/);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("carries each family's message spec", () => {
|
|
91
|
+
expect(registry.messages.families).toEqual(["sol", "gpg"]);
|
|
92
|
+
expect(registry.messages.resolve("solana")).toBe("sol");
|
|
93
|
+
expect(registry.messages.spec("gpg")?.address).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("refuses a family registered twice and a name two families claim", () => {
|
|
97
|
+
expect(() => createFamilyRegistry([defineWalletFamily(sol), defineWalletFamily(sol)])).toThrow(
|
|
98
|
+
/sol is registered twice/,
|
|
99
|
+
);
|
|
100
|
+
expect(() =>
|
|
101
|
+
createFamilyRegistry([
|
|
102
|
+
defineWalletFamily(sol),
|
|
103
|
+
defineWalletFamily({ ...gpg, aliases: ["solana"] }),
|
|
104
|
+
]),
|
|
105
|
+
).toThrow(/"solana" is claimed by sol and gpg/);
|
|
106
|
+
expect(() =>
|
|
107
|
+
createFamilyRegistry([
|
|
108
|
+
defineWalletFamily({ ...gpg, aliases: ["sol"] }),
|
|
109
|
+
defineWalletFamily(sol),
|
|
110
|
+
]),
|
|
111
|
+
).toThrow(/"sol" is claimed by gpg and sol/);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("the registry's family list cannot be changed", () => {
|
|
115
|
+
expect(Object.isFrozen(registry.families)).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ScreenDef } from "@multiplatform.one/connectkit";
|
|
2
|
+
import type { ComponentType, ReactNode } from "react";
|
|
3
|
+
import {
|
|
4
|
+
createMessageRegistry,
|
|
5
|
+
type WalletMessageRegistry,
|
|
6
|
+
type WalletMessageSpec,
|
|
7
|
+
} from "./message";
|
|
8
|
+
import { assertName, nameTable } from "./names";
|
|
9
|
+
import type { ConnectionDriver } from "./types";
|
|
10
|
+
|
|
11
|
+
/** What a family package hands the core: `eth({chains})`, `sol({rpcUrl})`, `gpg()`. */
|
|
12
|
+
export interface WalletFamilyDefinition {
|
|
13
|
+
/** Short family id, the one the Keycloak message names: `eth`, `sol`, `sui`, `btc`, `gpg`. */
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
/** Other names callers use for the family, such as the ecosystem name `evm` for `eth`. */
|
|
17
|
+
readonly aliases?: readonly string[];
|
|
18
|
+
readonly message: WalletMessageSpec;
|
|
19
|
+
/**
|
|
20
|
+
* Makes the family's connection driver. The store calls it once, the first
|
|
21
|
+
* time it needs the family, so a family nobody touches starts nothing.
|
|
22
|
+
*/
|
|
23
|
+
readonly driver?: () => ConnectionDriver;
|
|
24
|
+
/** Signs without a wallet connection (GPG). Such a family has no driver. */
|
|
25
|
+
readonly connectionless?: boolean;
|
|
26
|
+
/** Modal screens the family contributes. */
|
|
27
|
+
readonly screens?: readonly ScreenDef[];
|
|
28
|
+
/** A provider the family needs mounted around the app. */
|
|
29
|
+
readonly Provider?: ComponentType<{ children?: ReactNode }>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface WalletFamily extends WalletFamilyDefinition {
|
|
33
|
+
readonly aliases: readonly string[];
|
|
34
|
+
readonly connectionless: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Validates a family definition and freezes it. */
|
|
38
|
+
export function defineWalletFamily(definition: WalletFamilyDefinition): WalletFamily {
|
|
39
|
+
assertName("wallet family id", definition.id);
|
|
40
|
+
const aliases = [...(definition.aliases ?? [])];
|
|
41
|
+
for (const alias of aliases) {
|
|
42
|
+
assertName(`wallet family ${definition.id} alias`, alias);
|
|
43
|
+
if (alias === definition.id) {
|
|
44
|
+
throw new Error(`wallet family ${definition.id} lists its own id as an alias`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (typeof definition.label !== "string" || !definition.label.trim()) {
|
|
48
|
+
throw new Error(`wallet family ${definition.id} needs a label`);
|
|
49
|
+
}
|
|
50
|
+
const { message } = definition;
|
|
51
|
+
if (!message || typeof message.header !== "string" || !message.header) {
|
|
52
|
+
throw new Error(`wallet family ${definition.id} needs a message spec with a header`);
|
|
53
|
+
}
|
|
54
|
+
const connectionless = definition.connectionless === true;
|
|
55
|
+
if (connectionless && definition.driver) {
|
|
56
|
+
throw new Error(`wallet family ${definition.id} is connectionless and cannot have a driver`);
|
|
57
|
+
}
|
|
58
|
+
if (!connectionless && typeof definition.driver !== "function") {
|
|
59
|
+
throw new Error(`wallet family ${definition.id} needs a driver, or connectionless: true`);
|
|
60
|
+
}
|
|
61
|
+
return Object.freeze({
|
|
62
|
+
...definition,
|
|
63
|
+
aliases: Object.freeze(aliases),
|
|
64
|
+
connectionless,
|
|
65
|
+
message: Object.freeze({ ...message }),
|
|
66
|
+
...(definition.screens ? { screens: Object.freeze([...definition.screens]) } : {}),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface FamilyRegistry {
|
|
71
|
+
/** In the order the app listed them, which is the connect list's order. */
|
|
72
|
+
readonly families: readonly WalletFamily[];
|
|
73
|
+
/** The family for an id or alias, or undefined. */
|
|
74
|
+
get(family: string): WalletFamily | undefined;
|
|
75
|
+
/** The family for an id or alias. Throws naming the registered families. */
|
|
76
|
+
require(family: string): WalletFamily;
|
|
77
|
+
readonly messages: WalletMessageRegistry;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The families one app registered. Refuses a family, id or alias registered twice. */
|
|
81
|
+
export function createFamilyRegistry(families: readonly WalletFamily[]): FamilyRegistry {
|
|
82
|
+
const list = Object.freeze([...families]);
|
|
83
|
+
const names = nameTable(list);
|
|
84
|
+
const byId = new Map(list.map((family) => [family.id, family]));
|
|
85
|
+
const get = (family: string) => {
|
|
86
|
+
const id = names.get(family);
|
|
87
|
+
return id === undefined ? undefined : byId.get(id);
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
families: list,
|
|
91
|
+
get,
|
|
92
|
+
require(family) {
|
|
93
|
+
const found = get(family);
|
|
94
|
+
if (found === undefined) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`wallet family ${family} is not registered; registered: ${list.map((entry) => entry.id).join(", ") || "none"}`,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return found;
|
|
100
|
+
},
|
|
101
|
+
messages: createMessageRegistry(list),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, relative } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
const src = fileURLToPath(new URL("..", import.meta.url));
|
|
8
|
+
const entry = fileURLToPath(new URL("./index.ts", import.meta.url));
|
|
9
|
+
|
|
10
|
+
function resolveRelative(from: string, specifier: string): string {
|
|
11
|
+
const base = join(dirname(from), specifier);
|
|
12
|
+
for (const candidate of [
|
|
13
|
+
`${base}.ts`,
|
|
14
|
+
`${base}.tsx`,
|
|
15
|
+
join(base, "index.ts"),
|
|
16
|
+
join(base, "index.tsx"),
|
|
17
|
+
]) {
|
|
18
|
+
if (existsSync(candidate)) return candidate;
|
|
19
|
+
}
|
|
20
|
+
throw new Error(`cannot resolve ${specifier} from ${from}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Specifiers a file loads at runtime: type-only imports and exports are erased. */
|
|
24
|
+
function runtimeSpecifiers(file: string): string[] {
|
|
25
|
+
const source = ts.createSourceFile(
|
|
26
|
+
file,
|
|
27
|
+
readFileSync(file, "utf8"),
|
|
28
|
+
ts.ScriptTarget.Latest,
|
|
29
|
+
true,
|
|
30
|
+
);
|
|
31
|
+
const found: string[] = [];
|
|
32
|
+
const visit = (node: ts.Node) => {
|
|
33
|
+
if (ts.isImportDeclaration(node) && !node.importClause?.isTypeOnly) {
|
|
34
|
+
found.push((node.moduleSpecifier as ts.StringLiteral).text);
|
|
35
|
+
} else if (ts.isExportDeclaration(node) && node.moduleSpecifier && !node.isTypeOnly) {
|
|
36
|
+
found.push((node.moduleSpecifier as ts.StringLiteral).text);
|
|
37
|
+
} else if (
|
|
38
|
+
ts.isCallExpression(node) &&
|
|
39
|
+
(node.expression.kind === ts.SyntaxKind.ImportKeyword ||
|
|
40
|
+
(ts.isIdentifier(node.expression) && node.expression.text === "require")) &&
|
|
41
|
+
node.arguments[0] &&
|
|
42
|
+
ts.isStringLiteral(node.arguments[0])
|
|
43
|
+
) {
|
|
44
|
+
found.push(node.arguments[0].text);
|
|
45
|
+
}
|
|
46
|
+
ts.forEachChild(node, visit);
|
|
47
|
+
};
|
|
48
|
+
visit(source);
|
|
49
|
+
return found;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function runtimeGraph(start: string) {
|
|
53
|
+
const files = new Set<string>();
|
|
54
|
+
const packages = new Map<string, string>();
|
|
55
|
+
const walk = (file: string) => {
|
|
56
|
+
if (files.has(file)) return;
|
|
57
|
+
files.add(file);
|
|
58
|
+
for (const specifier of runtimeSpecifiers(file)) {
|
|
59
|
+
if (specifier.startsWith(".")) walk(resolveRelative(file, specifier));
|
|
60
|
+
else packages.set(specifier, relative(src, file));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
walk(start);
|
|
64
|
+
return { files: [...files].map((file) => relative(src, file)).sort(), packages };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
describe("the core entry", () => {
|
|
68
|
+
it("loads no chain SDK: only React and its own files", () => {
|
|
69
|
+
const { files, packages } = runtimeGraph(entry);
|
|
70
|
+
expect(Object.fromEntries(packages)).toEqual({ react: "core/react.ts" });
|
|
71
|
+
expect(files.every((file) => file.startsWith("core/") || file === "clients/types.ts")).toBe(
|
|
72
|
+
true,
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("the scan sees a runtime import it should refuse", () => {
|
|
77
|
+
const { packages } = runtimeGraph(
|
|
78
|
+
fileURLToPath(new URL("../message/index.ts", import.meta.url)),
|
|
79
|
+
);
|
|
80
|
+
expect(packages.has("viem")).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Core contracts of mpo web3 (MPO-385): the family registry, the connection
|
|
2
|
+
// driver interface, the connection store and the message registry. Nothing here
|
|
3
|
+
// imports a chain SDK; each family package brings its own driver and message.
|
|
4
|
+
export {
|
|
5
|
+
createFamilyRegistry,
|
|
6
|
+
defineWalletFamily,
|
|
7
|
+
type FamilyRegistry,
|
|
8
|
+
type WalletFamily,
|
|
9
|
+
type WalletFamilyDefinition,
|
|
10
|
+
} from "./family";
|
|
11
|
+
export {
|
|
12
|
+
createMessageRegistry,
|
|
13
|
+
formatWalletMessage,
|
|
14
|
+
type MessageFamily,
|
|
15
|
+
type WalletMessageRegistry,
|
|
16
|
+
type WalletMessageSpec,
|
|
17
|
+
} from "./message";
|
|
18
|
+
export {
|
|
19
|
+
createConnectionStore,
|
|
20
|
+
defaultConnectionStorageKey,
|
|
21
|
+
type ConnectionStore,
|
|
22
|
+
type ConnectionStoreOptions,
|
|
23
|
+
type FamilyConnector,
|
|
24
|
+
} from "./store";
|
|
25
|
+
export {
|
|
26
|
+
ConnectionProvider,
|
|
27
|
+
useConnection,
|
|
28
|
+
useConnectionStore,
|
|
29
|
+
type ConnectionProviderProps,
|
|
30
|
+
} from "./react";
|
|
31
|
+
export type {
|
|
32
|
+
ConnectionDriver,
|
|
33
|
+
ConnectionState,
|
|
34
|
+
ConnectionStatus,
|
|
35
|
+
ConnectionStorage,
|
|
36
|
+
DriverAccount,
|
|
37
|
+
DriverConnectOptions,
|
|
38
|
+
DriverState,
|
|
39
|
+
SavedConnection,
|
|
40
|
+
WalletConnector,
|
|
41
|
+
} from "./types";
|
|
42
|
+
export {
|
|
43
|
+
UnsupportedClientMethodError,
|
|
44
|
+
type ChainClient,
|
|
45
|
+
type ClientCapability,
|
|
46
|
+
type ClientFamily,
|
|
47
|
+
} from "../clients/types";
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { getAddress } from "viem";
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { buildWalletMessage, type SignerFamily } from "../message/buildWalletMessage";
|
|
4
|
+
import { createMessageRegistry, formatWalletMessage, type MessageFamily } from "./message";
|
|
5
|
+
|
|
6
|
+
// The five families as their packages will register them. Kept in step with
|
|
7
|
+
// buildWalletMessage, which every Keycloak golden test already pins.
|
|
8
|
+
const families: MessageFamily[] = [
|
|
9
|
+
{
|
|
10
|
+
id: "eth",
|
|
11
|
+
aliases: ["evm"],
|
|
12
|
+
message: {
|
|
13
|
+
header: "wants you to sign in with your Ethereum account:",
|
|
14
|
+
statement: "Sign in With Ethereum.",
|
|
15
|
+
chainId: "1",
|
|
16
|
+
numericChainId: true,
|
|
17
|
+
keepStatementLine: true,
|
|
18
|
+
normalizeAddress: (address) => getAddress(address),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "sol",
|
|
23
|
+
aliases: ["solana"],
|
|
24
|
+
message: {
|
|
25
|
+
header: "wants you to sign in with your Solana account:",
|
|
26
|
+
statement: "Sign in With Solana.",
|
|
27
|
+
chainId: "solana:mainnet",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "sui",
|
|
32
|
+
message: {
|
|
33
|
+
header: "wants you to sign in with your Sui account:",
|
|
34
|
+
statement: "Sign in With Sui.",
|
|
35
|
+
chainId: "sui:mainnet",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "btc",
|
|
40
|
+
aliases: ["bitcoin"],
|
|
41
|
+
message: {
|
|
42
|
+
header: "wants you to sign in with your Bitcoin account:",
|
|
43
|
+
statement: "Sign in With Bitcoin.",
|
|
44
|
+
chainId: "bitcoin",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "gpg",
|
|
49
|
+
message: {
|
|
50
|
+
header: "wants you to sign in with your GPG key.",
|
|
51
|
+
statement: null,
|
|
52
|
+
chainId: null,
|
|
53
|
+
address: false,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const registry = createMessageRegistry(families);
|
|
59
|
+
const names: SignerFamily[] = ["eth", "evm", "sol", "solana", "sui", "btc", "bitcoin", "gpg"];
|
|
60
|
+
const base = {
|
|
61
|
+
domain: "app.multiplatform.one",
|
|
62
|
+
uri: "https://app.multiplatform.one/login",
|
|
63
|
+
nonce: "ohY7vD2Kq9",
|
|
64
|
+
issuedAt: "2026-09-26T20:48:18.648Z",
|
|
65
|
+
address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const outcome = (build: () => string) => {
|
|
69
|
+
try {
|
|
70
|
+
return { message: build() };
|
|
71
|
+
} catch {
|
|
72
|
+
return { threw: true };
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
afterEach(() => {
|
|
77
|
+
vi.unstubAllGlobals();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe("the core message registry", () => {
|
|
81
|
+
it("builds the same bytes as buildWalletMessage for every family, alias and option", () => {
|
|
82
|
+
let compared = 0;
|
|
83
|
+
for (const family of names) {
|
|
84
|
+
for (const statement of [undefined, null, "", "Custom statement."]) {
|
|
85
|
+
for (const chainId of [undefined, 137, "solana:devnet", 900001]) {
|
|
86
|
+
for (const version of [undefined, "2"]) {
|
|
87
|
+
const opts = { ...base, statement, chainId, version };
|
|
88
|
+
expect(registry.build(family, opts), `${family} ${JSON.stringify(opts)}`).toBe(
|
|
89
|
+
buildWalletMessage(family, opts),
|
|
90
|
+
);
|
|
91
|
+
compared++;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
expect(compared).toBe(256);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("refuses what buildWalletMessage refuses", () => {
|
|
100
|
+
for (const family of names) {
|
|
101
|
+
for (const opts of [
|
|
102
|
+
{ ...base, address: undefined },
|
|
103
|
+
{ ...base, domain: "evil.example\nURI: https://evil.example" },
|
|
104
|
+
{ ...base, uri: "https://a\nb" },
|
|
105
|
+
{ ...base, statement: "two\nlines" },
|
|
106
|
+
]) {
|
|
107
|
+
expect(outcome(() => registry.build(family, opts))).toEqual(
|
|
108
|
+
outcome(() => buildWalletMessage(family, opts)),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("takes domain and uri from the page like buildWalletMessage", () => {
|
|
115
|
+
for (const location of [
|
|
116
|
+
{ host: "shop.example", origin: "https://shop.example" },
|
|
117
|
+
{ host: "file.example", origin: "null" },
|
|
118
|
+
{ host: "", origin: "" },
|
|
119
|
+
]) {
|
|
120
|
+
vi.stubGlobal("location", location);
|
|
121
|
+
for (const family of names) {
|
|
122
|
+
const opts = { nonce: base.nonce, issuedAt: base.issuedAt, address: base.address };
|
|
123
|
+
expect(outcome(() => registry.build(family, opts))).toEqual(
|
|
124
|
+
outcome(() => buildWalletMessage(family, opts)),
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("resolves aliases and lists families in registration order", () => {
|
|
131
|
+
expect(registry.families).toEqual(["eth", "sol", "sui", "btc", "gpg"]);
|
|
132
|
+
expect(registry.resolve("evm")).toBe("eth");
|
|
133
|
+
expect(registry.resolve("cosmos")).toBeUndefined();
|
|
134
|
+
expect(registry.spec("bitcoin")?.chainId).toBe("bitcoin");
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("names the registered families when asked for another", () => {
|
|
138
|
+
expect(() => registry.build("cosmos", base)).toThrow(
|
|
139
|
+
"no wallet message for family cosmos; registered: eth, sol, sui, btc, gpg",
|
|
140
|
+
);
|
|
141
|
+
expect(() => createMessageRegistry([]).build("eth", base)).toThrow(/registered: none/);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("a new family needs only a spec", () => {
|
|
145
|
+
const cosmos = createMessageRegistry([
|
|
146
|
+
{
|
|
147
|
+
id: "cosmos",
|
|
148
|
+
message: {
|
|
149
|
+
header: "wants you to sign in with your Cosmos account:",
|
|
150
|
+
statement: "Sign in With Cosmos.",
|
|
151
|
+
chainId: "cosmoshub-4",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
]);
|
|
155
|
+
expect(cosmos.build("cosmos", { ...base, address: "cosmos1abc" }).split("\n")).toEqual([
|
|
156
|
+
"app.multiplatform.one wants you to sign in with your Cosmos account:",
|
|
157
|
+
"cosmos1abc",
|
|
158
|
+
"",
|
|
159
|
+
"Sign in With Cosmos.",
|
|
160
|
+
"",
|
|
161
|
+
"URI: https://app.multiplatform.one/login",
|
|
162
|
+
"Version: 1",
|
|
163
|
+
"Chain ID: cosmoshub-4",
|
|
164
|
+
"Nonce: ohY7vD2Kq9",
|
|
165
|
+
"Issued At: 2026-09-26T20:48:18.648Z",
|
|
166
|
+
]);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("formatWalletMessage names the family in its errors", () => {
|
|
170
|
+
expect(() =>
|
|
171
|
+
formatWalletMessage(
|
|
172
|
+
{ header: "wants you to sign in:", statement: null, chainId: null },
|
|
173
|
+
{ ...base, address: undefined },
|
|
174
|
+
"sol",
|
|
175
|
+
),
|
|
176
|
+
).toThrow("wallet message: sol needs an address");
|
|
177
|
+
});
|
|
178
|
+
});
|