thirdweb 5.64.3-nightly-ddec3dadcc260e0d4d0ed2b43c502e0915a14203-20241029000326 → 5.64.3
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/react/core/utils/isSmartWallet.js +4 -2
- package/dist/cjs/react/core/utils/isSmartWallet.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +23 -17
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -1
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-info.js +4 -13
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-info.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +56 -4
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/index.js +2 -50
- package/dist/cjs/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/esm/react/core/utils/isSmartWallet.js +4 -2
- package/dist/esm/react/core/utils/isSmartWallet.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +2 -2
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +22 -16
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -1
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-info.js +4 -13
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-info.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +56 -4
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/index.js +2 -50
- package/dist/esm/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/types/react/core/utils/isSmartWallet.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts +5 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts.map +1 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-info.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/in-app-core.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/index.d.ts +2 -3
- package/dist/types/wallets/in-app/core/wallet/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/react/core/utils/isSmartWallet.ts +4 -2
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +2 -2
- package/src/version.ts +1 -1
- package/src/wallets/ecosystem/get-ecosystem-wallet-auth-options.ts +36 -23
- package/src/wallets/ecosystem/get-ecosystem-wallet-info.ts +5 -21
- package/src/wallets/in-app/core/wallet/in-app-core.ts +62 -4
- package/src/wallets/in-app/core/wallet/index.ts +0 -59
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { getEcosystemInfo } from "./get-ecosystem-wallet-auth-options.js";
|
2
2
|
/**
|
3
3
|
* Fetches metadata for a given ecosystem wallet.
|
4
4
|
*
|
@@ -8,21 +8,12 @@ import { getThirdwebBaseUrl } from "../../utils/domains.js";
|
|
8
8
|
* @internal
|
9
9
|
*/
|
10
10
|
export async function getEcosystemWalletInfo(walletId) {
|
11
|
-
const
|
12
|
-
headers: {
|
13
|
-
"x-ecosystem-id": walletId,
|
14
|
-
},
|
15
|
-
});
|
16
|
-
const data = await res.json();
|
17
|
-
if (!data || data.code === "UNAUTHORIZED") {
|
18
|
-
throw new Error(data.message ||
|
19
|
-
`Could not find ecosystem wallet with id ${walletId}, please check your ecosystem wallet configuration.`);
|
20
|
-
}
|
11
|
+
const data = await getEcosystemInfo(walletId);
|
21
12
|
return {
|
22
13
|
id: walletId,
|
23
14
|
name: data.name,
|
24
|
-
image_id: data.imageUrl,
|
25
|
-
homepage: data.homepage,
|
15
|
+
image_id: data.imageUrl || "",
|
16
|
+
homepage: data.homepage || "",
|
26
17
|
rdns: null,
|
27
18
|
app: {
|
28
19
|
browser: null,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-ecosystem-wallet-info.js","sourceRoot":"","sources":["../../../../src/wallets/ecosystem/get-ecosystem-wallet-info.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"get-ecosystem-wallet-info.js","sourceRoot":"","sources":["../../../../src/wallets/ecosystem/get-ecosystem-wallet-info.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,QAA2B;IAE3B,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;QAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;QAC7B,IAAI,EAAE,IAAI;QACV,GAAG,EAAE;YACH,OAAO,EAAE,IAAI;YACb,GAAG,EAAE,IAAI;YACT,OAAO,EAAE,IAAI;YACb,GAAG,EAAE,IAAI;YACT,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,IAAI;SACX;QACD,MAAM,EAAE;YACN,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,IAAI;SAChB;QACD,OAAO,EAAE;YACP,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,IAAI;SAChB;KACF,CAAC;AACJ,CAAC"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { trackConnect } from "../../../../analytics/track/connect.js";
|
2
2
|
import { getCachedChainIfExists } from "../../../../chains/utils.js";
|
3
|
+
import { getEcosystemInfo } from "../../../ecosystem/get-ecosystem-wallet-auth-options.js";
|
3
4
|
import { createWalletEmitter } from "../../../wallet-emitter.js";
|
4
5
|
const connectorCache = new Map();
|
5
6
|
/**
|
@@ -18,9 +19,10 @@ export async function getOrCreateInAppWalletConnector(client, connectorFactory,
|
|
18
19
|
* @internal
|
19
20
|
*/
|
20
21
|
export function createInAppWallet(args) {
|
21
|
-
const { createOptions, connectorFactory, ecosystem } = args;
|
22
|
+
const { createOptions: _createOptions, connectorFactory, ecosystem } = args;
|
22
23
|
const walletId = ecosystem ? ecosystem.id : "inApp";
|
23
24
|
const emitter = createWalletEmitter();
|
25
|
+
let createOptions = _createOptions;
|
24
26
|
let account = undefined;
|
25
27
|
let chain = undefined;
|
26
28
|
let client;
|
@@ -39,7 +41,25 @@ export function createInAppWallet(args) {
|
|
39
41
|
autoConnect: async (options) => {
|
40
42
|
const { autoConnectInAppWallet } = await import("./index.js");
|
41
43
|
const connector = await getOrCreateInAppWalletConnector(options.client, connectorFactory, ecosystem);
|
42
|
-
|
44
|
+
if (ecosystem) {
|
45
|
+
const ecosystemOptions = await getEcosystemInfo(ecosystem.id);
|
46
|
+
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
47
|
+
if (smartAccountOptions) {
|
48
|
+
const preferredChain = options.chain;
|
49
|
+
if (!preferredChain) {
|
50
|
+
throw new Error("Chain is required for ecosystem smart accounts, pass it via connect() or via UI components");
|
51
|
+
}
|
52
|
+
createOptions = {
|
53
|
+
...createOptions,
|
54
|
+
smartAccount: {
|
55
|
+
chain: preferredChain,
|
56
|
+
sponsorGas: smartAccountOptions.sponsorGas,
|
57
|
+
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
58
|
+
},
|
59
|
+
};
|
60
|
+
}
|
61
|
+
}
|
62
|
+
const [connectedAccount, connectedChain] = await autoConnectInAppWallet(options, createOptions, connector);
|
43
63
|
// set the states
|
44
64
|
client = options.client;
|
45
65
|
account = connectedAccount;
|
@@ -56,7 +76,25 @@ export function createInAppWallet(args) {
|
|
56
76
|
connect: async (options) => {
|
57
77
|
const { connectInAppWallet } = await import("./index.js");
|
58
78
|
const connector = await getOrCreateInAppWalletConnector(options.client, connectorFactory, ecosystem);
|
59
|
-
|
79
|
+
if (ecosystem) {
|
80
|
+
const ecosystemOptions = await getEcosystemInfo(ecosystem.id);
|
81
|
+
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
82
|
+
if (smartAccountOptions) {
|
83
|
+
const preferredChain = options.chain;
|
84
|
+
if (!preferredChain) {
|
85
|
+
throw new Error("Chain is required for ecosystem smart accounts, pass it via connect() or via UI components");
|
86
|
+
}
|
87
|
+
createOptions = {
|
88
|
+
...createOptions,
|
89
|
+
smartAccount: {
|
90
|
+
chain: preferredChain,
|
91
|
+
sponsorGas: smartAccountOptions.sponsorGas,
|
92
|
+
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
93
|
+
},
|
94
|
+
};
|
95
|
+
}
|
96
|
+
}
|
97
|
+
const [connectedAccount, connectedChain] = await connectInAppWallet(options, createOptions, connector);
|
60
98
|
// set the states
|
61
99
|
client = options.client;
|
62
100
|
account = connectedAccount;
|
@@ -88,10 +126,24 @@ export function createInAppWallet(args) {
|
|
88
126
|
// if account abstraction is enabled, reconnect to smart account on the new chain
|
89
127
|
const { autoConnectInAppWallet } = await import("./index.js");
|
90
128
|
const connector = await getOrCreateInAppWalletConnector(client, connectorFactory, ecosystem);
|
129
|
+
if (ecosystem) {
|
130
|
+
const ecosystemOptions = await getEcosystemInfo(ecosystem.id);
|
131
|
+
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
132
|
+
if (smartAccountOptions) {
|
133
|
+
createOptions = {
|
134
|
+
...createOptions,
|
135
|
+
smartAccount: {
|
136
|
+
chain: newChain,
|
137
|
+
sponsorGas: smartAccountOptions.sponsorGas,
|
138
|
+
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
139
|
+
},
|
140
|
+
};
|
141
|
+
}
|
142
|
+
}
|
91
143
|
const [connectedAccount, connectedChain] = await autoConnectInAppWallet({
|
92
144
|
chain: newChain,
|
93
145
|
client,
|
94
|
-
}, createOptions, connector
|
146
|
+
}, createOptions, connector);
|
95
147
|
account = connectedAccount;
|
96
148
|
chain = connectedChain;
|
97
149
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"in-app-core.js","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/in-app-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;
|
1
|
+
{"version":3,"file":"in-app-core.js","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/in-app-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yDAAyD,CAAC;AAE3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAQjE,MAAM,cAAc,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEzD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,MAAsB,EACtB,gBAAqE,EACrE,SAAqB;IAErB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,C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K,GAAG,QAAQ,CAAC;YACnB,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QACzC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import { ethereum } from "../../../../chains/chain-definitions/ethereum.js";
|
2
|
-
import { getCachedChain } from "../../../../chains/utils.js";
|
3
2
|
import { socialAuthOptions, } from "../../../../wallets/types.js";
|
4
|
-
import { getEcosystemOptions } from "../../../ecosystem/get-ecosystem-wallet-auth-options.js";
|
5
3
|
/**
|
6
4
|
* Checks if the provided wallet is an in-app wallet.
|
7
5
|
*
|
@@ -14,7 +12,7 @@ export function isInAppWallet(wallet) {
|
|
14
12
|
/**
|
15
13
|
* @internal
|
16
14
|
*/
|
17
|
-
export async function connectInAppWallet(options, createOptions, connector
|
15
|
+
export async function connectInAppWallet(options, createOptions, connector) {
|
18
16
|
if (
|
19
17
|
// if auth mode is not specified, the default is popup
|
20
18
|
createOptions?.auth?.mode !== "popup" &&
|
@@ -40,35 +38,12 @@ export async function connectInAppWallet(options, createOptions, connector, ecos
|
|
40
38
|
chain: options.chain,
|
41
39
|
});
|
42
40
|
}
|
43
|
-
if (ecosystem) {
|
44
|
-
const ecosystemOptions = await getEcosystemOptions(ecosystem.id);
|
45
|
-
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
46
|
-
if (smartAccountOptions) {
|
47
|
-
const allowedChains = smartAccountOptions.chainIds;
|
48
|
-
const firstAllowedChain = allowedChains[0];
|
49
|
-
if (!firstAllowedChain) {
|
50
|
-
throw new Error("At least one chain must be allowed for ecosystem smart account");
|
51
|
-
}
|
52
|
-
const preferredChain = options.chain && allowedChains.includes(options.chain.id)
|
53
|
-
? options.chain
|
54
|
-
: getCachedChain(firstAllowedChain);
|
55
|
-
return convertToSmartAccount({
|
56
|
-
client: options.client,
|
57
|
-
authAccount,
|
58
|
-
smartAccountOptions: {
|
59
|
-
chain: preferredChain,
|
60
|
-
sponsorGas: smartAccountOptions.sponsorGas,
|
61
|
-
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
62
|
-
},
|
63
|
-
});
|
64
|
-
}
|
65
|
-
}
|
66
41
|
return [authAccount, options.chain || ethereum];
|
67
42
|
}
|
68
43
|
/**
|
69
44
|
* @internal
|
70
45
|
*/
|
71
|
-
export async function autoConnectInAppWallet(options, createOptions, connector
|
46
|
+
export async function autoConnectInAppWallet(options, createOptions, connector) {
|
72
47
|
if (options.authResult && connector.loginWithAuthToken) {
|
73
48
|
await connector.loginWithAuthToken(options.authResult);
|
74
49
|
}
|
@@ -87,29 +62,6 @@ export async function autoConnectInAppWallet(options, createOptions, connector,
|
|
87
62
|
chain: options.chain,
|
88
63
|
});
|
89
64
|
}
|
90
|
-
if (ecosystem) {
|
91
|
-
const ecosystemOptions = await getEcosystemOptions(ecosystem.id);
|
92
|
-
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
93
|
-
if (smartAccountOptions) {
|
94
|
-
const allowedChains = smartAccountOptions.chainIds;
|
95
|
-
const firstAllowedChain = allowedChains[0];
|
96
|
-
if (!firstAllowedChain) {
|
97
|
-
throw new Error("At least one chain must be allowed for ecosystem smart account");
|
98
|
-
}
|
99
|
-
const preferredChain = options.chain && allowedChains.includes(options.chain.id)
|
100
|
-
? options.chain
|
101
|
-
: getCachedChain(firstAllowedChain);
|
102
|
-
return convertToSmartAccount({
|
103
|
-
client: options.client,
|
104
|
-
authAccount,
|
105
|
-
smartAccountOptions: {
|
106
|
-
chain: preferredChain,
|
107
|
-
sponsorGas: smartAccountOptions.sponsorGas,
|
108
|
-
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
109
|
-
},
|
110
|
-
});
|
111
|
-
}
|
112
|
-
}
|
113
65
|
return [authAccount, options.chain || ethereum];
|
114
66
|
}
|
115
67
|
async function convertToSmartAccount(options) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kDAAkD,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kDAAkD,CAAC;AAG5E,OAAO,EAEL,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AAUtC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAwB;IAExB,OAAO,MAAM,CAAC,EAAE,KAAK,OAAO,IAAI,MAAM,CAAC,EAAE,KAAK,UAAU,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAE6C,EAC7C,aAE0C,EAC1C,SAAyB;IAEzB;IACE,sDAAsD;IACtD,aAAa,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO;QACrC,aAAa,EAAE,IAAI,EAAE,IAAI,KAAK,SAAS;QACvC,SAAS,CAAC,wBAAwB,EAClC,CAAC;QACD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,iBAAiB,CAAC,QAAQ,CAAC,QAA4B,CAAC,EAAE,CAAC;YAC7D,SAAS,CAAC,wBAAwB,CAChC,QAA4B,EAC5B,aAAa,EAAE,IAAI,EAAE,IAAI,EACzB,aAAa,EAAE,IAAI,EAAE,WAAW,CACjC,CAAC;QACJ,CAAC;IACH,CAAC;IACD,6HAA6H;IAC7H,uGAAuG;IACvG,6CAA6C;IAE7C,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;IAE5C,IACE,aAAa;QACb,cAAc,IAAI,aAAa;QAC/B,aAAa,EAAE,YAAY,EAC3B,CAAC;QACD,OAAO,qBAAqB,CAAC;YAC3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AClC,CAAC,CAAC;IAEH,MAAM,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpD,OAAO,kBAAkB,CACvB,EAAE,EACF;QACE,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,eAAe,EAAE,OAAO,CAAC,WAAW;QACpC,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,EACD,OAAO,CAAC,mBAAmB,CAC5B,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,SAAyB;IAC3D,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;IACvC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,+BAA+B,CAAC,CAAC,CAAC;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isSmartWallet.d.ts","sourceRoot":"","sources":["../../../../../src/react/core/utils/isSmartWallet.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"isSmartWallet.d.ts","sourceRoot":"","sources":["../../../../../src/react/core/utils/isSmartWallet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAEpE,wBAAgB,eAAe,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAQ9D"}
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.64.3
|
1
|
+
export declare const version = "5.64.3";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
@@ -1,6 +1,10 @@
|
|
1
1
|
import type { AuthOption } from "../types.js";
|
2
2
|
import type { EcosystemWalletId } from "../wallet-types.js";
|
3
3
|
export type EcosystemOptions = {
|
4
|
+
name: string;
|
5
|
+
imageUrl?: string;
|
6
|
+
slug: string;
|
7
|
+
homepage?: string;
|
4
8
|
authOptions: AuthOption[];
|
5
9
|
smartAccountOptions: SmartAccountOptions;
|
6
10
|
};
|
@@ -15,6 +19,6 @@ type SmartAccountOptions = {
|
|
15
19
|
* @returns {AuthOption[] | undefined} The auth options for the ecosystem wallet.
|
16
20
|
* @internal
|
17
21
|
*/
|
18
|
-
export declare function
|
22
|
+
export declare function getEcosystemInfo(walletId: EcosystemWalletId): Promise<EcosystemOptions>;
|
19
23
|
export {};
|
20
24
|
//# sourceMappingURL=get-ecosystem-wallet-auth-options.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-ecosystem-wallet-auth-options.d.ts","sourceRoot":"","sources":["../../../../src/wallets/ecosystem/get-ecosystem-wallet-auth-options.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"get-ecosystem-wallet-auth-options.d.ts","sourceRoot":"","sources":["../../../../src/wallets/ecosystem/get-ecosystem-wallet-auth-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAkC3B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-ecosystem-wallet-info.d.ts","sourceRoot":"","sources":["../../../../src/wallets/ecosystem/get-ecosystem-wallet-info.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"get-ecosystem-wallet-info.d.ts","sourceRoot":"","sources":["../../../../src/wallets/ecosystem/get-ecosystem-wallet-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CA+B/B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"in-app-core.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/in-app-core.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;
|
1
|
+
{"version":3,"file":"in-app-core.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/in-app-core.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,KAAK,EAAW,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C;;GAEG;AACH,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,cAAc,EACtB,gBAAgB,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC,EACrE,SAAS,CAAC,EAAE,SAAS,2BAStB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,aAAa,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,gBAAgB,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACtE,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,MAAM,CAAC,OAAO,GAAG,iBAAiB,CAAC,CAiLtC"}
|
@@ -3,7 +3,6 @@ import type { Account, Wallet } from "../../../interfaces/wallet.js";
|
|
3
3
|
import type { EcosystemWalletId, WalletId } from "../../../wallet-types.js";
|
4
4
|
import type { CreateWalletArgs, WalletAutoConnectionOption, WalletConnectionOption } from "../../../wallet-types.js";
|
5
5
|
import type { InAppConnector } from "../interfaces/connector.js";
|
6
|
-
import type { Ecosystem } from "./types.js";
|
7
6
|
/**
|
8
7
|
* Checks if the provided wallet is an in-app wallet.
|
9
8
|
*
|
@@ -14,9 +13,9 @@ export declare function isInAppWallet(wallet: Wallet<WalletId>): wallet is Walle
|
|
14
13
|
/**
|
15
14
|
* @internal
|
16
15
|
*/
|
17
|
-
export declare function connectInAppWallet(options: WalletConnectionOption<"inApp"> | WalletConnectionOption<EcosystemWalletId>, createOptions: CreateWalletArgs<"inApp">[1] | CreateWalletArgs<EcosystemWalletId>[1], connector: InAppConnector
|
16
|
+
export declare function connectInAppWallet(options: WalletConnectionOption<"inApp"> | WalletConnectionOption<EcosystemWalletId>, createOptions: CreateWalletArgs<"inApp">[1] | CreateWalletArgs<EcosystemWalletId>[1], connector: InAppConnector): Promise<[Account, Chain]>;
|
18
17
|
/**
|
19
18
|
* @internal
|
20
19
|
*/
|
21
|
-
export declare function autoConnectInAppWallet(options: WalletAutoConnectionOption<"inApp"> | WalletAutoConnectionOption<EcosystemWalletId>, createOptions: CreateWalletArgs<"inApp">[1] | CreateWalletArgs<EcosystemWalletId>[1], connector: InAppConnector
|
20
|
+
export declare function autoConnectInAppWallet(options: WalletAutoConnectionOption<"inApp"> | WalletAutoConnectionOption<EcosystemWalletId>, createOptions: CreateWalletArgs<"inApp">[1] | CreateWalletArgs<EcosystemWalletId>[1], connector: InAppConnector): Promise<[Account, Chain]>;
|
22
21
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAMzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,GACvB,MAAM,IAAI,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,CAExC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EACH,sBAAsB,CAAC,OAAO,CAAC,GAC/B,sBAAsB,CAAC,iBAAiB,CAAC,EAC7C,aAAa,EACT,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAC5B,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAC1C,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAqC3B;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EACH,0BAA0B,CAAC,OAAO,CAAC,GACnC,0BAA0B,CAAC,iBAAiB,CAAC,EACjD,aAAa,EACT,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAC5B,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAC1C,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CA0B3B"}
|
package/package.json
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
import { isEcosystemWallet } from "../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
1
2
|
import type { Wallet } from "../../../wallets/interfaces/wallet.js";
|
2
3
|
|
3
4
|
export function hasSmartAccount(activeWallet?: Wallet): boolean {
|
4
5
|
const config = activeWallet?.getConfig();
|
5
6
|
return (
|
6
|
-
|
7
|
+
activeWallet !== undefined &&
|
7
8
|
(activeWallet.id === "smart" ||
|
8
|
-
(activeWallet.id === "inApp" && !!config && "smartAccount" in config)
|
9
|
+
(activeWallet.id === "inApp" && !!config && "smartAccount" in config) ||
|
10
|
+
(isEcosystemWallet(activeWallet) && !!config && "smartAccount" in config))
|
9
11
|
);
|
10
12
|
}
|
@@ -5,7 +5,7 @@ import { useMemo, useState } from "react";
|
|
5
5
|
import type { Chain } from "../../../../chains/types.js";
|
6
6
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
7
7
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
8
|
-
import {
|
8
|
+
import { getEcosystemInfo } from "../../../../wallets/ecosystem/get-ecosystem-wallet-auth-options.js";
|
9
9
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
10
10
|
import type { Profile } from "../../../../wallets/in-app/core/authentication/types.js";
|
11
11
|
import { linkProfile } from "../../../../wallets/in-app/web/lib/auth/index.js";
|
@@ -123,7 +123,7 @@ export const ConnectWalletSocialOptions = (
|
|
123
123
|
queryKey: ["auth-options", wallet.id],
|
124
124
|
queryFn: async () => {
|
125
125
|
if (isEcosystemWallet(wallet)) {
|
126
|
-
const options = await
|
126
|
+
const options = await getEcosystemInfo(wallet.id);
|
127
127
|
return options?.authOptions ?? null;
|
128
128
|
}
|
129
129
|
return null;
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.64.3
|
1
|
+
export const version = "5.64.3";
|
@@ -1,8 +1,13 @@
|
|
1
1
|
import { getThirdwebBaseUrl } from "../../utils/domains.js";
|
2
|
+
import { withCache } from "../../utils/promise/withCache.js";
|
2
3
|
import type { AuthOption } from "../types.js";
|
3
4
|
import type { EcosystemWalletId } from "../wallet-types.js";
|
4
5
|
|
5
6
|
export type EcosystemOptions = {
|
7
|
+
name: string;
|
8
|
+
imageUrl?: string;
|
9
|
+
slug: string;
|
10
|
+
homepage?: string;
|
6
11
|
authOptions: AuthOption[];
|
7
12
|
smartAccountOptions: SmartAccountOptions;
|
8
13
|
};
|
@@ -19,32 +24,40 @@ type SmartAccountOptions = {
|
|
19
24
|
* @returns {AuthOption[] | undefined} The auth options for the ecosystem wallet.
|
20
25
|
* @internal
|
21
26
|
*/
|
22
|
-
export async function
|
27
|
+
export async function getEcosystemInfo(
|
23
28
|
walletId: EcosystemWalletId,
|
24
|
-
): Promise<EcosystemOptions
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
): Promise<EcosystemOptions> {
|
30
|
+
return withCache(
|
31
|
+
async () => {
|
32
|
+
const res = await fetch(
|
33
|
+
`${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/ecosystem-wallet`,
|
34
|
+
{
|
35
|
+
headers: {
|
36
|
+
"x-ecosystem-id": walletId,
|
37
|
+
},
|
38
|
+
},
|
39
|
+
);
|
33
40
|
|
34
|
-
|
41
|
+
const data = await res.json();
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
if (!data || data.code === "UNAUTHORIZED") {
|
44
|
+
throw new Error(
|
45
|
+
data.message ||
|
46
|
+
`Could not find ecosystem wallet with id ${walletId}, please check your ecosystem wallet configuration.`,
|
47
|
+
);
|
48
|
+
}
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
50
|
+
// siwe is the auth option in the backend, but we want to use wallet as the auth option in the frontend
|
51
|
+
if (data.authOptions?.includes("siwe")) {
|
52
|
+
data.authOptions = data.authOptions.filter((o: string) => o !== "siwe");
|
53
|
+
data.authOptions.push("wallet");
|
54
|
+
}
|
48
55
|
|
49
|
-
|
56
|
+
return data;
|
57
|
+
},
|
58
|
+
{
|
59
|
+
cacheKey: `ecosystem-wallet-options-${walletId}`,
|
60
|
+
cacheTime: 1000 * 60 * 5, // 5 mins
|
61
|
+
},
|
62
|
+
);
|
50
63
|
}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { getThirdwebBaseUrl } from "../../utils/domains.js";
|
2
1
|
import type { Prettify } from "../../utils/type-utils.js";
|
3
2
|
import type { WalletInfo } from "../wallet-info.js";
|
4
3
|
import type { EcosystemWalletId } from "../wallet-types.js";
|
4
|
+
import { getEcosystemInfo } from "./get-ecosystem-wallet-auth-options.js";
|
5
5
|
|
6
6
|
/**
|
7
7
|
* Fetches metadata for a given ecosystem wallet.
|
@@ -14,29 +14,13 @@ import type { EcosystemWalletId } from "../wallet-types.js";
|
|
14
14
|
export async function getEcosystemWalletInfo(
|
15
15
|
walletId: EcosystemWalletId,
|
16
16
|
): Promise<Prettify<WalletInfo>> {
|
17
|
-
const
|
18
|
-
`${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/ecosystem-wallet`,
|
19
|
-
{
|
20
|
-
headers: {
|
21
|
-
"x-ecosystem-id": walletId,
|
22
|
-
},
|
23
|
-
},
|
24
|
-
);
|
25
|
-
|
26
|
-
const data = await res.json();
|
27
|
-
|
28
|
-
if (!data || data.code === "UNAUTHORIZED") {
|
29
|
-
throw new Error(
|
30
|
-
data.message ||
|
31
|
-
`Could not find ecosystem wallet with id ${walletId}, please check your ecosystem wallet configuration.`,
|
32
|
-
);
|
33
|
-
}
|
17
|
+
const data = await getEcosystemInfo(walletId);
|
34
18
|
|
35
19
|
return {
|
36
20
|
id: walletId,
|
37
|
-
name: data.name
|
38
|
-
image_id: data.imageUrl
|
39
|
-
homepage: data.homepage
|
21
|
+
name: data.name,
|
22
|
+
image_id: data.imageUrl || "",
|
23
|
+
homepage: data.homepage || "",
|
40
24
|
rdns: null,
|
41
25
|
app: {
|
42
26
|
browser: null,
|
@@ -2,6 +2,7 @@ import { trackConnect } from "../../../../analytics/track/connect.js";
|
|
2
2
|
import type { Chain } from "../../../../chains/types.js";
|
3
3
|
import { getCachedChainIfExists } from "../../../../chains/utils.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
5
|
+
import { getEcosystemInfo } from "../../../ecosystem/get-ecosystem-wallet-auth-options.js";
|
5
6
|
import type { Account, Wallet } from "../../../interfaces/wallet.js";
|
6
7
|
import { createWalletEmitter } from "../../../wallet-emitter.js";
|
7
8
|
import type {
|
@@ -38,9 +39,10 @@ export function createInAppWallet(args: {
|
|
38
39
|
connectorFactory: (client: ThirdwebClient) => Promise<InAppConnector>;
|
39
40
|
ecosystem?: Ecosystem;
|
40
41
|
}): Wallet<"inApp" | EcosystemWalletId> {
|
41
|
-
const { createOptions, connectorFactory, ecosystem } = args;
|
42
|
+
const { createOptions: _createOptions, connectorFactory, ecosystem } = args;
|
42
43
|
const walletId = ecosystem ? ecosystem.id : "inApp";
|
43
44
|
const emitter = createWalletEmitter<"inApp">();
|
45
|
+
let createOptions = _createOptions;
|
44
46
|
let account: Account | undefined = undefined;
|
45
47
|
let chain: Chain | undefined = undefined;
|
46
48
|
let client: ThirdwebClient | undefined;
|
@@ -66,11 +68,32 @@ export function createInAppWallet(args: {
|
|
66
68
|
connectorFactory,
|
67
69
|
ecosystem,
|
68
70
|
);
|
71
|
+
|
72
|
+
if (ecosystem) {
|
73
|
+
const ecosystemOptions = await getEcosystemInfo(ecosystem.id);
|
74
|
+
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
75
|
+
if (smartAccountOptions) {
|
76
|
+
const preferredChain = options.chain;
|
77
|
+
if (!preferredChain) {
|
78
|
+
throw new Error(
|
79
|
+
"Chain is required for ecosystem smart accounts, pass it via connect() or via UI components",
|
80
|
+
);
|
81
|
+
}
|
82
|
+
createOptions = {
|
83
|
+
...createOptions,
|
84
|
+
smartAccount: {
|
85
|
+
chain: preferredChain,
|
86
|
+
sponsorGas: smartAccountOptions.sponsorGas,
|
87
|
+
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
88
|
+
},
|
89
|
+
};
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
69
93
|
const [connectedAccount, connectedChain] = await autoConnectInAppWallet(
|
70
94
|
options,
|
71
95
|
createOptions,
|
72
96
|
connector,
|
73
|
-
ecosystem,
|
74
97
|
);
|
75
98
|
|
76
99
|
// set the states
|
@@ -94,11 +117,31 @@ export function createInAppWallet(args: {
|
|
94
117
|
ecosystem,
|
95
118
|
);
|
96
119
|
|
120
|
+
if (ecosystem) {
|
121
|
+
const ecosystemOptions = await getEcosystemInfo(ecosystem.id);
|
122
|
+
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
123
|
+
if (smartAccountOptions) {
|
124
|
+
const preferredChain = options.chain;
|
125
|
+
if (!preferredChain) {
|
126
|
+
throw new Error(
|
127
|
+
"Chain is required for ecosystem smart accounts, pass it via connect() or via UI components",
|
128
|
+
);
|
129
|
+
}
|
130
|
+
createOptions = {
|
131
|
+
...createOptions,
|
132
|
+
smartAccount: {
|
133
|
+
chain: preferredChain,
|
134
|
+
sponsorGas: smartAccountOptions.sponsorGas,
|
135
|
+
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
136
|
+
},
|
137
|
+
};
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
97
141
|
const [connectedAccount, connectedChain] = await connectInAppWallet(
|
98
142
|
options,
|
99
143
|
createOptions,
|
100
144
|
connector,
|
101
|
-
ecosystem,
|
102
145
|
);
|
103
146
|
// set the states
|
104
147
|
client = options.client;
|
@@ -139,6 +182,22 @@ export function createInAppWallet(args: {
|
|
139
182
|
connectorFactory,
|
140
183
|
ecosystem,
|
141
184
|
);
|
185
|
+
|
186
|
+
if (ecosystem) {
|
187
|
+
const ecosystemOptions = await getEcosystemInfo(ecosystem.id);
|
188
|
+
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
189
|
+
if (smartAccountOptions) {
|
190
|
+
createOptions = {
|
191
|
+
...createOptions,
|
192
|
+
smartAccount: {
|
193
|
+
chain: newChain,
|
194
|
+
sponsorGas: smartAccountOptions.sponsorGas,
|
195
|
+
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
196
|
+
},
|
197
|
+
};
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
142
201
|
const [connectedAccount, connectedChain] = await autoConnectInAppWallet(
|
143
202
|
{
|
144
203
|
chain: newChain,
|
@@ -146,7 +205,6 @@ export function createInAppWallet(args: {
|
|
146
205
|
},
|
147
206
|
createOptions,
|
148
207
|
connector,
|
149
|
-
ecosystem,
|
150
208
|
);
|
151
209
|
account = connectedAccount;
|
152
210
|
chain = connectedChain;
|