@cartridge/controller 0.7.13-alpha.2 → 0.7.13-alpha.4
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/.turbo/turbo-build$colon$deps.log +16 -16
- package/.turbo/turbo-build.log +13 -13
- package/dist/index.js +297 -174
- package/dist/index.js.map +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/{provider-LFJfEvkl.js → provider-DhfZ5TCx.js} +2 -2
- package/dist/{provider-LFJfEvkl.js.map → provider-DhfZ5TCx.js.map} +1 -1
- package/dist/session.js +2 -2
- package/dist/stats.html +1 -1
- package/dist/wallets/metamask/index.d.ts +1 -0
- package/dist/wallets/rabby/index.d.ts +1 -0
- package/dist/wallets/types.d.ts +1 -0
- package/dist/wallets/wallet-connect/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/wallets/bridge.ts +8 -4
- package/src/wallets/metamask/index.ts +16 -0
- package/src/wallets/rabby/index.ts +10 -8
- package/src/wallets/types.ts +1 -0
- package/src/wallets/wallet-connect/index.ts +6 -1
package/dist/wallets/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class WalletConnectWallet implements WalletAdapter {
|
|
|
5
5
|
readonly type: ExternalWalletType;
|
|
6
6
|
readonly platform: ExternalPlatform;
|
|
7
7
|
private account;
|
|
8
|
-
constructor(provider: Provider);
|
|
8
|
+
constructor(provider: Provider, account?: string);
|
|
9
9
|
isAvailable(): boolean;
|
|
10
10
|
getInfo(): ExternalWallet;
|
|
11
11
|
connect(): Promise<ExternalWalletResponse<any>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cartridge/controller",
|
|
3
|
-
"version": "0.7.13-alpha.
|
|
3
|
+
"version": "0.7.13-alpha.4",
|
|
4
4
|
"description": "Cartridge Controller",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"cbor-x": "^1.5.0",
|
|
37
37
|
"mipd": "^0.0.7",
|
|
38
38
|
"@walletconnect/ethereum-provider": "^2.20.0",
|
|
39
|
-
"@cartridge/account-wasm": "0.7.13-alpha.
|
|
40
|
-
"@cartridge/utils": "0.7.13-alpha.
|
|
39
|
+
"@cartridge/account-wasm": "0.7.13-alpha.4",
|
|
40
|
+
"@cartridge/utils": "0.7.13-alpha.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/jest": "^29.5.14",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"vite-plugin-node-polyfills": "^0.22.0",
|
|
54
54
|
"vite-plugin-top-level-await": "^1.4.4",
|
|
55
55
|
"vite-plugin-wasm": "^3.4.1",
|
|
56
|
-
"@cartridge/tsconfig": "0.7.13-alpha.
|
|
56
|
+
"@cartridge/tsconfig": "0.7.13-alpha.4"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build:deps": "pnpm build",
|
package/src/wallets/bridge.ts
CHANGED
|
@@ -20,10 +20,14 @@ export class WalletBridge {
|
|
|
20
20
|
|
|
21
21
|
constructor() {
|
|
22
22
|
this.walletAdapters = new Map<ExternalWalletType, WalletAdapter>();
|
|
23
|
-
|
|
24
|
-
this.walletAdapters.set("
|
|
25
|
-
|
|
26
|
-
this.walletAdapters.set("
|
|
23
|
+
const metamask = new MetaMaskWallet();
|
|
24
|
+
metamask.isAvailable() && this.walletAdapters.set("metamask", metamask);
|
|
25
|
+
const phantom = new PhantomWallet();
|
|
26
|
+
phantom.isAvailable() && this.walletAdapters.set("phantom", phantom);
|
|
27
|
+
const argent = new ArgentWallet();
|
|
28
|
+
argent.isAvailable() && this.walletAdapters.set("argent", argent);
|
|
29
|
+
const rabby = new RabbyWallet();
|
|
30
|
+
rabby.isAvailable() && this.walletAdapters.set("rabby", rabby);
|
|
27
31
|
|
|
28
32
|
if (typeof window !== "undefined") {
|
|
29
33
|
window.wallet_bridge = this;
|
|
@@ -12,6 +12,7 @@ export class MetaMaskWallet implements WalletAdapter {
|
|
|
12
12
|
readonly platform: ExternalPlatform = "ethereum";
|
|
13
13
|
private MMSDK: MetaMaskSDK;
|
|
14
14
|
private account: string | undefined = undefined;
|
|
15
|
+
private connectedAccounts: string[] = [];
|
|
15
16
|
|
|
16
17
|
constructor() {
|
|
17
18
|
this.MMSDK = new MetaMaskSDK({
|
|
@@ -20,6 +21,19 @@ export class MetaMaskWallet implements WalletAdapter {
|
|
|
20
21
|
url: window.location.href,
|
|
21
22
|
},
|
|
22
23
|
});
|
|
24
|
+
this.MMSDK.sdkInitPromise?.then(() => {
|
|
25
|
+
this.MMSDK.getProvider()
|
|
26
|
+
?.request({
|
|
27
|
+
method: "eth_accounts",
|
|
28
|
+
})
|
|
29
|
+
.then((accounts: any) => {
|
|
30
|
+
if (accounts && accounts.length > 0) {
|
|
31
|
+
console.log(accounts);
|
|
32
|
+
this.account = accounts[0];
|
|
33
|
+
this.connectedAccounts = accounts;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
23
37
|
}
|
|
24
38
|
|
|
25
39
|
isAvailable(): boolean {
|
|
@@ -36,6 +50,7 @@ export class MetaMaskWallet implements WalletAdapter {
|
|
|
36
50
|
chainId: available ? window.ethereum?.chainId : undefined,
|
|
37
51
|
name: "MetaMask",
|
|
38
52
|
platform: this.platform,
|
|
53
|
+
connectedAccounts: this.connectedAccounts,
|
|
39
54
|
};
|
|
40
55
|
}
|
|
41
56
|
|
|
@@ -52,6 +67,7 @@ export class MetaMaskWallet implements WalletAdapter {
|
|
|
52
67
|
const accounts = await this.MMSDK.connect();
|
|
53
68
|
if (accounts && accounts.length > 0) {
|
|
54
69
|
this.account = accounts[0];
|
|
70
|
+
this.connectedAccounts = accounts;
|
|
55
71
|
return { success: true, wallet: this.type, account: this.account };
|
|
56
72
|
}
|
|
57
73
|
|
|
@@ -15,19 +15,19 @@ export class RabbyWallet implements WalletAdapter {
|
|
|
15
15
|
private account: string | undefined = undefined;
|
|
16
16
|
private store = createStore();
|
|
17
17
|
private provider: EIP6963ProviderDetail | undefined;
|
|
18
|
+
private connectedAccounts: string[] = [];
|
|
18
19
|
|
|
19
20
|
constructor() {
|
|
20
21
|
this.provider = this.store
|
|
21
22
|
.getProviders()
|
|
22
23
|
.find((provider) => provider.info.rdns === RABBY_RDNS);
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
}
|
|
30
|
-
});
|
|
24
|
+
this.provider?.provider
|
|
25
|
+
.request({
|
|
26
|
+
method: "eth_accounts",
|
|
27
|
+
})
|
|
28
|
+
.then((accounts) => {
|
|
29
|
+
this.connectedAccounts = accounts;
|
|
30
|
+
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
isAvailable(): boolean {
|
|
@@ -44,6 +44,7 @@ export class RabbyWallet implements WalletAdapter {
|
|
|
44
44
|
chainId: available ? window.ethereum?.chainId : undefined,
|
|
45
45
|
name: "Rabby",
|
|
46
46
|
platform: this.platform,
|
|
47
|
+
connectedAccounts: this.connectedAccounts,
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -62,6 +63,7 @@ export class RabbyWallet implements WalletAdapter {
|
|
|
62
63
|
});
|
|
63
64
|
if (accounts && accounts.length > 0) {
|
|
64
65
|
this.account = accounts[0];
|
|
66
|
+
this.connectedAccounts = accounts;
|
|
65
67
|
return { success: true, wallet: this.type, account: this.account };
|
|
66
68
|
}
|
|
67
69
|
|
package/src/wallets/types.ts
CHANGED
|
@@ -12,7 +12,12 @@ export class WalletConnectWallet implements WalletAdapter {
|
|
|
12
12
|
readonly platform: ExternalPlatform = "ethereum";
|
|
13
13
|
private account: string | undefined = undefined;
|
|
14
14
|
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(
|
|
16
|
+
private provider: Provider,
|
|
17
|
+
account?: string,
|
|
18
|
+
) {
|
|
19
|
+
this.account = account;
|
|
20
|
+
}
|
|
16
21
|
|
|
17
22
|
isAvailable(): boolean {
|
|
18
23
|
return !!this.provider;
|