@dynamic-labs/global-wallet-client 4.0.0-alpha.48 → 4.0.0-alpha.49
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/CHANGELOG.md +29 -0
- package/_virtual/_tslib.cjs +36 -0
- package/_virtual/_tslib.js +32 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +24 -4
- package/src/ethereum.cjs +12 -0
- package/src/ethereum.d.ts +1 -0
- package/src/ethereum.js +3 -0
- package/src/index.cjs +2 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/lib/actions/connectAction/createConnectAction.cjs +38 -0
- package/src/lib/actions/connectAction/createConnectAction.d.ts +10 -0
- package/src/lib/actions/connectAction/createConnectAction.js +34 -0
- package/src/lib/actions/connectAction/index.d.ts +1 -0
- package/src/lib/actions/disconnectAction/createDisconnectAction.cjs +11 -0
- package/src/lib/actions/disconnectAction/createDisconnectAction.d.ts +7 -0
- package/src/lib/actions/disconnectAction/createDisconnectAction.js +7 -0
- package/src/lib/actions/disconnectAction/index.d.ts +1 -0
- package/src/lib/constants/logger.cjs +10 -0
- package/src/lib/constants/logger.d.ts +2 -0
- package/src/lib/constants/logger.js +6 -0
- package/src/lib/createGlobalWalletClient.cjs +44 -0
- package/src/lib/createGlobalWalletClient.d.ts +54 -0
- package/src/lib/createGlobalWalletClient.js +40 -0
- package/src/lib/ethereum/functions/announceEIP6963Provider/announceEIP6963Provider.cjs +29 -0
- package/src/lib/ethereum/functions/announceEIP6963Provider/announceEIP6963Provider.d.ts +12 -0
- package/src/lib/ethereum/functions/announceEIP6963Provider/announceEIP6963Provider.js +25 -0
- package/src/lib/ethereum/functions/announceEIP6963Provider/index.d.ts +1 -0
- package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.cjs +88 -0
- package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.d.ts +3 -0
- package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.js +84 -0
- package/src/lib/ethereum/functions/eip1193Provider/index.d.ts +1 -0
- package/src/lib/ethereum/index.d.ts +2 -0
- package/src/lib/functions/createClientEventEmitter/createClientEventEmitter.cjs +10 -0
- package/src/lib/functions/createClientEventEmitter/createClientEventEmitter.d.ts +6 -0
- package/src/lib/functions/createClientEventEmitter/createClientEventEmitter.js +6 -0
- package/src/lib/functions/createClientEventEmitter/index.d.ts +1 -0
- package/src/lib/functions/createPopupOpener/createPopupOpener.cjs +52 -0
- package/src/lib/functions/createPopupOpener/createPopupOpener.d.ts +15 -0
- package/src/lib/functions/createPopupOpener/createPopupOpener.js +48 -0
- package/src/lib/functions/createPopupOpener/index.d.ts +1 -0
- package/src/lib/functions/mergeAndEncryptParams/index.d.ts +1 -0
- package/src/lib/functions/mergeAndEncryptParams/mergeAndEncryptParams.cjs +23 -0
- package/src/lib/functions/mergeAndEncryptParams/mergeAndEncryptParams.d.ts +2 -0
- package/src/lib/functions/mergeAndEncryptParams/mergeAndEncryptParams.js +19 -0
- package/src/lib/functions/mergeURLSearchParams/index.d.ts +1 -0
- package/src/lib/functions/mergeURLSearchParams/mergeURLSearchParams.cjs +17 -0
- package/src/lib/functions/mergeURLSearchParams/mergeURLSearchParams.d.ts +6 -0
- package/src/lib/functions/mergeURLSearchParams/mergeURLSearchParams.js +13 -0
- package/src/lib/functions/onPopupClose/index.d.ts +1 -0
- package/src/lib/functions/onPopupClose/onPopupClose.cjs +22 -0
- package/src/lib/functions/onPopupClose/onPopupClose.d.ts +8 -0
- package/src/lib/functions/onPopupClose/onPopupClose.js +18 -0
- package/src/lib/functions/waitForPopupResponse/index.d.ts +1 -0
- package/src/lib/functions/waitForPopupResponse/waitForPopupResponse.cjs +55 -0
- package/src/lib/functions/waitForPopupResponse/waitForPopupResponse.d.ts +9 -0
- package/src/lib/functions/waitForPopupResponse/waitForPopupResponse.js +51 -0
- package/src/lib/store/createClientStore.cjs +67 -0
- package/src/lib/store/createClientStore.d.ts +34 -0
- package/src/lib/store/createClientStore.js +63 -0
- package/src/lib/store/index.d.ts +1 -0
- package/src/lib/types.d.ts +37 -0
- package/src/lib/global-wallet-client.cjs +0 -8
- package/src/lib/global-wallet-client.d.ts +0 -1
- package/src/lib/global-wallet-client.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.49](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.48...v4.0.0-alpha.49) (2024-12-27)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* change openFunding to openExternalFunding (#7684)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* aa blockaid simulations ([#7583](https://github.com/dynamic-labs/dynamic-auth/issues/7583)) ([6436220](https://github.com/dynamic-labs/dynamic-auth/commit/64362204d2c96291a37bf281d62531d6f2384fdf))
|
|
12
|
+
* add ethereum createConnector function ([#7607](https://github.com/dynamic-labs/dynamic-auth/issues/7607)) ([f306537](https://github.com/dynamic-labs/dynamic-auth/commit/f3065372f3c5dfc8bf26173dc722576e614af5e1))
|
|
13
|
+
* add fundWithExternalWallet method to useFunding ([#7688](https://github.com/dynamic-labs/dynamic-auth/issues/7688)) ([d48b1d2](https://github.com/dynamic-labs/dynamic-auth/commit/d48b1d2568ba928b322a4d81b6386e775ae4aa98))
|
|
14
|
+
* change openFunding to openExternalFunding ([#7684](https://github.com/dynamic-labs/dynamic-auth/issues/7684)) ([8efb9cb](https://github.com/dynamic-labs/dynamic-auth/commit/8efb9cb9ca3d7e2273c14e18f7be5892e50b8e12))
|
|
15
|
+
* connect global wallet in ethereum ([#7619](https://github.com/dynamic-labs/dynamic-auth/issues/7619)) ([fdb7f00](https://github.com/dynamic-labs/dynamic-auth/commit/fdb7f00c33f7da3ac95ae13ac674caa64b453cae))
|
|
16
|
+
* create wallet groups dynamically based on wallet options ([#7662](https://github.com/dynamic-labs/dynamic-auth/issues/7662)) ([981affc](https://github.com/dynamic-labs/dynamic-auth/commit/981affce5518f6532d960fe4e879e9cf40a66ce7))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **ethereum:** normalize user reject error from injected wallets ([#7702](https://github.com/dynamic-labs/dynamic-auth/issues/7702)) ([ce456a8](https://github.com/dynamic-labs/dynamic-auth/commit/ce456a8592197b07857baf32bb1b38867ffb37fe))
|
|
22
|
+
* fetch nonce when authenticating a user that connected in connect-only mode ([#7689](https://github.com/dynamic-labs/dynamic-auth/issues/7689)) ([f048bb9](https://github.com/dynamic-labs/dynamic-auth/commit/f048bb96b6cb5ae603966b2813f900a082cd158f))
|
|
23
|
+
* filter out wallets for the current network when using external wallet funding ([#7694](https://github.com/dynamic-labs/dynamic-auth/issues/7694)) ([65db665](https://github.com/dynamic-labs/dynamic-auth/commit/65db6652a934561e7d07379a65d2baa8f7813d8e))
|
|
24
|
+
* remove toaccount from signmessage and signtypeddata for zerodev ([#7650](https://github.com/dynamic-labs/dynamic-auth/issues/7650)) ([626e849](https://github.com/dynamic-labs/dynamic-auth/commit/626e849a4af3af51d60b42dd2787edb05126744b))
|
|
25
|
+
* save nonce to storage ([#7698](https://github.com/dynamic-labs/dynamic-auth/issues/7698)) ([93dc65b](https://github.com/dynamic-labs/dynamic-auth/commit/93dc65b7f78040367b85420c1374f3cafbfb598b))
|
|
26
|
+
* **sdk-react-core:** add timeout when getting connected accounts ([#7697](https://github.com/dynamic-labs/dynamic-auth/issues/7697)) ([9a4bd7c](https://github.com/dynamic-labs/dynamic-auth/commit/9a4bd7c02795205ec98d8d71aba75b51b9bbee7c))
|
|
27
|
+
* update auth token from new source ([#7666](https://github.com/dynamic-labs/dynamic-auth/issues/7666)) ([61798de](https://github.com/dynamic-labs/dynamic-auth/commit/61798de26d759db9064f5f84118540346a44ab50))
|
|
28
|
+
* update extension update_url endpoint ([#7655](https://github.com/dynamic-labs/dynamic-auth/issues/7655)) ([46cff3a](https://github.com/dynamic-labs/dynamic-auth/commit/46cff3a80c9efee659a764df47f927ed5a117079))
|
|
29
|
+
* zerodev confirmation UI closes properly ([#7664](https://github.com/dynamic-labs/dynamic-auth/issues/7664)) ([a78aded](https://github.com/dynamic-labs/dynamic-auth/commit/a78adedc054d09134198d22812aa5cab7bbff548))
|
|
30
|
+
|
|
2
31
|
## [4.0.0-alpha.48](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.47...v4.0.0-alpha.48) (2024-12-17)
|
|
3
32
|
|
|
4
33
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
|
|
21
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
+
var e = new Error(message);
|
|
33
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.__awaiter = __awaiter;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
|
|
17
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
28
|
+
var e = new Error(message);
|
|
29
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { __awaiter };
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/global-wallet-client",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.49",
|
|
4
4
|
"description": "Core package for building Dynamic's Global Wallet",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "./src/index.cjs",
|
|
8
8
|
"module": "./src/index.js",
|
|
9
9
|
"types": "./src/index.d.ts",
|
|
10
|
+
"typings": "./src/index.d.ts",
|
|
10
11
|
"type": "module",
|
|
12
|
+
"typesVersions": {
|
|
13
|
+
"*": {
|
|
14
|
+
"ethereum": [
|
|
15
|
+
"./src/ethereum.d.ts"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
11
19
|
"exports": {
|
|
12
20
|
".": {
|
|
13
21
|
"types": "./src/index.d.ts",
|
|
14
22
|
"import": "./src/index.js",
|
|
15
|
-
"
|
|
23
|
+
"default": "./src/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./ethereum": {
|
|
26
|
+
"types": "./src/ethereum.d.ts",
|
|
27
|
+
"import": "./src/ethereum.js",
|
|
28
|
+
"default": "./src/ethereum.cjs"
|
|
16
29
|
},
|
|
17
30
|
"./package.json": "./package.json"
|
|
18
31
|
},
|
|
19
32
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
33
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
34
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.49",
|
|
35
|
+
"@dynamic-labs/logger": "4.0.0-alpha.49",
|
|
36
|
+
"@dynamic-labs/store": "4.0.0-alpha.49",
|
|
37
|
+
"@dynamic-labs/types": "4.0.0-alpha.49",
|
|
38
|
+
"@dynamic-labs/utils": "4.0.0-alpha.49",
|
|
39
|
+
"eventemitter3": "5.0.1"
|
|
22
40
|
},
|
|
23
|
-
"peerDependencies": {
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"viem": "^2.7.12"
|
|
43
|
+
}
|
|
24
44
|
}
|
package/src/ethereum.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var announceEIP6963Provider = require('./lib/ethereum/functions/announceEIP6963Provider/announceEIP6963Provider.cjs');
|
|
7
|
+
var createEIP1193Provider = require('./lib/ethereum/functions/eip1193Provider/createEIP1193Provider.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.announceEip6963Provider = announceEIP6963Provider.announceEip6963Provider;
|
|
12
|
+
exports.createEIP1193Provider = createEIP1193Provider.createEIP1193Provider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { announceEip6963Provider, createEIP1193Provider } from './lib/ethereum';
|
package/src/ethereum.js
ADDED
package/src/index.cjs
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
7
|
var _package = require('../package.cjs');
|
|
8
|
-
var
|
|
8
|
+
var createGlobalWalletClient = require('./lib/createGlobalWalletClient.cjs');
|
|
9
9
|
|
|
10
10
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/global-wallet-client', _package.version);
|
|
11
11
|
|
|
12
|
-
exports.
|
|
12
|
+
exports.createGlobalWalletClient = createGlobalWalletClient.createGlobalWalletClient;
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { createGlobalWalletClient, type GlobalWalletClient, } from './lib/createGlobalWalletClient';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
3
|
import { version } from '../package.js';
|
|
4
|
-
export {
|
|
4
|
+
export { createGlobalWalletClient } from './lib/createGlobalWalletClient.js';
|
|
5
5
|
|
|
6
6
|
assertPackageVersion('@dynamic-labs/global-wallet-client', version);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
|
|
9
|
+
const createConnectAction = ({ store, openPopup, onConnect }) => (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ chain }) {
|
|
10
|
+
store.clear();
|
|
11
|
+
const keyPair = yield utils.createKeyPair();
|
|
12
|
+
const data = yield openPopup({
|
|
13
|
+
params: {
|
|
14
|
+
chain,
|
|
15
|
+
receiver_public_key: yield utils.convertPublicKeyCryptoKeyToHex(keyPair.publicKey),
|
|
16
|
+
},
|
|
17
|
+
pathname: 'connect',
|
|
18
|
+
});
|
|
19
|
+
const { encryptedMessage, expiresAt, iv, providerPublicKey } = data;
|
|
20
|
+
const sharedSecret = yield utils.deriveSharedSecret(keyPair.privateKey, yield utils.convertPublicKeyHexToCryptoKey(providerPublicKey));
|
|
21
|
+
const message = yield utils.decryptMessage(sharedSecret, encryptedMessage, iv);
|
|
22
|
+
const { network, wallet } = JSON.parse(message);
|
|
23
|
+
const connection = {
|
|
24
|
+
evm: {
|
|
25
|
+
network,
|
|
26
|
+
supportedNetworks: [],
|
|
27
|
+
wallets: [wallet],
|
|
28
|
+
},
|
|
29
|
+
expiresAt,
|
|
30
|
+
sharedSecret,
|
|
31
|
+
solana: null,
|
|
32
|
+
};
|
|
33
|
+
store.setConnection(connection);
|
|
34
|
+
onConnect === null || onConnect === void 0 ? void 0 : onConnect(connection);
|
|
35
|
+
return wallet;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
exports.createConnectAction = createConnectAction;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ClientStore } from '../../store';
|
|
2
|
+
import { OpenPopup } from '../../functions/createPopupOpener/createPopupOpener';
|
|
3
|
+
import { ConnectArgs, Connection } from '../../types';
|
|
4
|
+
type CreateConnectActionProps = {
|
|
5
|
+
store: ClientStore;
|
|
6
|
+
openPopup: OpenPopup;
|
|
7
|
+
onConnect?: (connection: Connection) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const createConnectAction: ({ store, openPopup, onConnect }: CreateConnectActionProps) => ({ chain }: ConnectArgs) => Promise<import("@dynamic-labs/types").BaseWallet>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
|
+
import { createKeyPair, convertPublicKeyCryptoKeyToHex, deriveSharedSecret, convertPublicKeyHexToCryptoKey, decryptMessage } from '@dynamic-labs/utils';
|
|
4
|
+
|
|
5
|
+
const createConnectAction = ({ store, openPopup, onConnect }) => (_a) => __awaiter(void 0, [_a], void 0, function* ({ chain }) {
|
|
6
|
+
store.clear();
|
|
7
|
+
const keyPair = yield createKeyPair();
|
|
8
|
+
const data = yield openPopup({
|
|
9
|
+
params: {
|
|
10
|
+
chain,
|
|
11
|
+
receiver_public_key: yield convertPublicKeyCryptoKeyToHex(keyPair.publicKey),
|
|
12
|
+
},
|
|
13
|
+
pathname: 'connect',
|
|
14
|
+
});
|
|
15
|
+
const { encryptedMessage, expiresAt, iv, providerPublicKey } = data;
|
|
16
|
+
const sharedSecret = yield deriveSharedSecret(keyPair.privateKey, yield convertPublicKeyHexToCryptoKey(providerPublicKey));
|
|
17
|
+
const message = yield decryptMessage(sharedSecret, encryptedMessage, iv);
|
|
18
|
+
const { network, wallet } = JSON.parse(message);
|
|
19
|
+
const connection = {
|
|
20
|
+
evm: {
|
|
21
|
+
network,
|
|
22
|
+
supportedNetworks: [],
|
|
23
|
+
wallets: [wallet],
|
|
24
|
+
},
|
|
25
|
+
expiresAt,
|
|
26
|
+
sharedSecret,
|
|
27
|
+
solana: null,
|
|
28
|
+
};
|
|
29
|
+
store.setConnection(connection);
|
|
30
|
+
onConnect === null || onConnect === void 0 ? void 0 : onConnect(connection);
|
|
31
|
+
return wallet;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export { createConnectAction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createConnectAction } from './createConnectAction';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const createDisconnectAction = ({ store, onDisconnect }) => () => {
|
|
7
|
+
store.clear();
|
|
8
|
+
onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.createDisconnectAction = createDisconnectAction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createDisconnectAction } from './createDisconnectAction';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var createConnectAction = require('./actions/connectAction/createConnectAction.cjs');
|
|
7
|
+
var createPopupOpener = require('./functions/createPopupOpener/createPopupOpener.cjs');
|
|
8
|
+
var createClientStore = require('./store/createClientStore.cjs');
|
|
9
|
+
var createClientEventEmitter = require('./functions/createClientEventEmitter/createClientEventEmitter.cjs');
|
|
10
|
+
var createDisconnectAction = require('./actions/disconnectAction/createDisconnectAction.cjs');
|
|
11
|
+
|
|
12
|
+
const createGlobalWalletClient = ({ environmentId, popup: popupInfo, }) => {
|
|
13
|
+
const eventEmitter = createClientEventEmitter.createClientEventEmitter();
|
|
14
|
+
const store = createClientStore.createClientStore();
|
|
15
|
+
const openPopup = createPopupOpener.createPopupOpener({ environmentId, popupInfo, store });
|
|
16
|
+
const connect = createConnectAction.createConnectAction({
|
|
17
|
+
onConnect: () => eventEmitter.emit('connect'),
|
|
18
|
+
openPopup,
|
|
19
|
+
store,
|
|
20
|
+
});
|
|
21
|
+
const disconnect = createDisconnectAction.createDisconnectAction({
|
|
22
|
+
onDisconnect: () => eventEmitter.emit('disconnect'),
|
|
23
|
+
store,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
connect,
|
|
27
|
+
disconnect,
|
|
28
|
+
get ethereum() {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
return (_b = (_a = store.getActiveConnection()) === null || _a === void 0 ? void 0 : _a.evm) !== null && _b !== void 0 ? _b : null;
|
|
31
|
+
},
|
|
32
|
+
invoke: openPopup,
|
|
33
|
+
off: eventEmitter.off.bind(eventEmitter),
|
|
34
|
+
on: eventEmitter.on.bind(eventEmitter),
|
|
35
|
+
once: eventEmitter.once.bind(eventEmitter),
|
|
36
|
+
removeAllListeners: eventEmitter.removeAllListeners.bind(eventEmitter),
|
|
37
|
+
removeListener: eventEmitter.removeListener.bind(eventEmitter),
|
|
38
|
+
get userWallets() {
|
|
39
|
+
return store.userWallets;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.createGlobalWalletClient = createGlobalWalletClient;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PopupInfo } from './types';
|
|
2
|
+
export type CreateGlobalWalletClientProps = {
|
|
3
|
+
environmentId: string;
|
|
4
|
+
popup: PopupInfo;
|
|
5
|
+
};
|
|
6
|
+
export declare const createGlobalWalletClient: ({ environmentId, popup: popupInfo, }: CreateGlobalWalletClientProps) => {
|
|
7
|
+
connect: ({ chain }: import("./types").ConnectArgs) => Promise<import("dist/packages/types/src").BaseWallet>;
|
|
8
|
+
disconnect: () => void;
|
|
9
|
+
readonly ethereum: {
|
|
10
|
+
supportedNetworks: {
|
|
11
|
+
chainId: number;
|
|
12
|
+
}[];
|
|
13
|
+
wallets: import("dist/packages/types/src").BaseWallet[];
|
|
14
|
+
network: string;
|
|
15
|
+
} | null;
|
|
16
|
+
invoke: <TPopupAction extends import("dist/packages/types/src").IPopupAction>({ params, pathname, }: {
|
|
17
|
+
params: import("dist/packages/types/src").GetPopupActionFuncArgs<TPopupAction>;
|
|
18
|
+
pathname: import("dist/packages/types/src").GetPopupActionName<TPopupAction>;
|
|
19
|
+
}) => Promise<import("dist/packages/types/src").GetPopupActionResult<TPopupAction>>;
|
|
20
|
+
off: <T extends "connect" | "disconnect">(event: T, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
21
|
+
connect: () => void;
|
|
22
|
+
disconnect: () => void;
|
|
23
|
+
}>[Extract<T, "connect" | "disconnect">]) => void) | undefined, context?: any, once?: boolean | undefined) => import("eventemitter3").EventEmitter<{
|
|
24
|
+
connect: () => void;
|
|
25
|
+
disconnect: () => void;
|
|
26
|
+
}, any>;
|
|
27
|
+
on: <T_1 extends "connect" | "disconnect">(event: T_1, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
28
|
+
connect: () => void;
|
|
29
|
+
disconnect: () => void;
|
|
30
|
+
}>[Extract<T_1, "connect" | "disconnect">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
|
|
31
|
+
connect: () => void;
|
|
32
|
+
disconnect: () => void;
|
|
33
|
+
}, any>;
|
|
34
|
+
once: <T_2 extends "connect" | "disconnect">(event: T_2, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
35
|
+
connect: () => void;
|
|
36
|
+
disconnect: () => void;
|
|
37
|
+
}>[Extract<T_2, "connect" | "disconnect">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
|
|
38
|
+
connect: () => void;
|
|
39
|
+
disconnect: () => void;
|
|
40
|
+
}, any>;
|
|
41
|
+
removeAllListeners: (event?: "connect" | "disconnect" | undefined) => import("eventemitter3").EventEmitter<{
|
|
42
|
+
connect: () => void;
|
|
43
|
+
disconnect: () => void;
|
|
44
|
+
}, any>;
|
|
45
|
+
removeListener: <T_3 extends "connect" | "disconnect">(event: T_3, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
46
|
+
connect: () => void;
|
|
47
|
+
disconnect: () => void;
|
|
48
|
+
}>[Extract<T_3, "connect" | "disconnect">]) => void) | undefined, context?: any, once?: boolean | undefined) => import("eventemitter3").EventEmitter<{
|
|
49
|
+
connect: () => void;
|
|
50
|
+
disconnect: () => void;
|
|
51
|
+
}, any>;
|
|
52
|
+
readonly userWallets: import("dist/packages/types/src").BaseWallet[];
|
|
53
|
+
};
|
|
54
|
+
export type GlobalWalletClient = ReturnType<typeof createGlobalWalletClient>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { createConnectAction } from './actions/connectAction/createConnectAction.js';
|
|
3
|
+
import { createPopupOpener } from './functions/createPopupOpener/createPopupOpener.js';
|
|
4
|
+
import { createClientStore } from './store/createClientStore.js';
|
|
5
|
+
import { createClientEventEmitter } from './functions/createClientEventEmitter/createClientEventEmitter.js';
|
|
6
|
+
import { createDisconnectAction } from './actions/disconnectAction/createDisconnectAction.js';
|
|
7
|
+
|
|
8
|
+
const createGlobalWalletClient = ({ environmentId, popup: popupInfo, }) => {
|
|
9
|
+
const eventEmitter = createClientEventEmitter();
|
|
10
|
+
const store = createClientStore();
|
|
11
|
+
const openPopup = createPopupOpener({ environmentId, popupInfo, store });
|
|
12
|
+
const connect = createConnectAction({
|
|
13
|
+
onConnect: () => eventEmitter.emit('connect'),
|
|
14
|
+
openPopup,
|
|
15
|
+
store,
|
|
16
|
+
});
|
|
17
|
+
const disconnect = createDisconnectAction({
|
|
18
|
+
onDisconnect: () => eventEmitter.emit('disconnect'),
|
|
19
|
+
store,
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
connect,
|
|
23
|
+
disconnect,
|
|
24
|
+
get ethereum() {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
return (_b = (_a = store.getActiveConnection()) === null || _a === void 0 ? void 0 : _a.evm) !== null && _b !== void 0 ? _b : null;
|
|
27
|
+
},
|
|
28
|
+
invoke: openPopup,
|
|
29
|
+
off: eventEmitter.off.bind(eventEmitter),
|
|
30
|
+
on: eventEmitter.on.bind(eventEmitter),
|
|
31
|
+
once: eventEmitter.once.bind(eventEmitter),
|
|
32
|
+
removeAllListeners: eventEmitter.removeAllListeners.bind(eventEmitter),
|
|
33
|
+
removeListener: eventEmitter.removeListener.bind(eventEmitter),
|
|
34
|
+
get userWallets() {
|
|
35
|
+
return store.userWallets;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { createGlobalWalletClient };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
let lastEventHandler;
|
|
7
|
+
const announceEip6963Provider = ({ info, provider, }) => {
|
|
8
|
+
var _a;
|
|
9
|
+
if (lastEventHandler) {
|
|
10
|
+
window.removeEventListener('eip6963:requestProvider', lastEventHandler);
|
|
11
|
+
}
|
|
12
|
+
const eip6963Event = {
|
|
13
|
+
info: {
|
|
14
|
+
icon: info.icon,
|
|
15
|
+
name: info.name,
|
|
16
|
+
rdns: info.rdns,
|
|
17
|
+
uuid: (_a = info.uuid) !== null && _a !== void 0 ? _a : crypto.randomUUID(),
|
|
18
|
+
},
|
|
19
|
+
provider,
|
|
20
|
+
};
|
|
21
|
+
lastEventHandler = () => {
|
|
22
|
+
window.dispatchEvent(new CustomEvent('eip6963:announceProvider', {
|
|
23
|
+
detail: eip6963Event,
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
window.addEventListener('eip6963:requestProvider', lastEventHandler);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.announceEip6963Provider = announceEip6963Provider;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EIP1193Provider } from 'viem';
|
|
2
|
+
type AnnounceEip6963ProviderProps = {
|
|
3
|
+
info: {
|
|
4
|
+
icon: `data:image/png;base64,${string}`;
|
|
5
|
+
name: string;
|
|
6
|
+
rdns: string;
|
|
7
|
+
uuid?: string;
|
|
8
|
+
};
|
|
9
|
+
provider: EIP1193Provider;
|
|
10
|
+
};
|
|
11
|
+
export declare const announceEip6963Provider: ({ info, provider, }: AnnounceEip6963ProviderProps) => void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
let lastEventHandler;
|
|
3
|
+
const announceEip6963Provider = ({ info, provider, }) => {
|
|
4
|
+
var _a;
|
|
5
|
+
if (lastEventHandler) {
|
|
6
|
+
window.removeEventListener('eip6963:requestProvider', lastEventHandler);
|
|
7
|
+
}
|
|
8
|
+
const eip6963Event = {
|
|
9
|
+
info: {
|
|
10
|
+
icon: info.icon,
|
|
11
|
+
name: info.name,
|
|
12
|
+
rdns: info.rdns,
|
|
13
|
+
uuid: (_a = info.uuid) !== null && _a !== void 0 ? _a : crypto.randomUUID(),
|
|
14
|
+
},
|
|
15
|
+
provider,
|
|
16
|
+
};
|
|
17
|
+
lastEventHandler = () => {
|
|
18
|
+
window.dispatchEvent(new CustomEvent('eip6963:announceProvider', {
|
|
19
|
+
detail: eip6963Event,
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
window.addEventListener('eip6963:requestProvider', lastEventHandler);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { announceEip6963Provider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { announceEip6963Provider } from './announceEIP6963Provider';
|