@dynamic-labs/ethereum-aa 1.0.0-alpha.1
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 +2039 -0
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/_virtual/_tslib.cjs +30 -0
- package/_virtual/_tslib.js +26 -0
- package/package.json +40 -0
- package/src/ZeroDevConnector.cjs +138 -0
- package/src/ZeroDevConnector.d.ts +35 -0
- package/src/ZeroDevConnector.js +134 -0
- package/src/ethereum-aa.cjs +8 -0
- package/src/ethereum-aa.d.ts +2 -0
- package/src/ethereum-aa.js +4 -0
- package/src/index.cjs +18 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Dynamic Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/******************************************************************************
|
|
6
|
+
Copyright (c) Microsoft Corporation.
|
|
7
|
+
|
|
8
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
+
purpose with or without fee is hereby granted.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
+
***************************************************************************** */
|
|
19
|
+
|
|
20
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.__awaiter = __awaiter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { __awaiter };
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamic-labs/ethereum-aa",
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
7
|
+
"directory": "packages/ethereum-aa"
|
|
8
|
+
},
|
|
9
|
+
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/dynamic-labs/DynamicAuth/issues"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/dynamic-labs/DynamicAuth#readme",
|
|
14
|
+
"author": "Dynamic Labs, Inc.",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"main": "./src/index.cjs",
|
|
17
|
+
"module": "./src/index.js",
|
|
18
|
+
"types": "./src/index.d.ts",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./src/index.d.ts",
|
|
23
|
+
"import": "./src/index.js",
|
|
24
|
+
"require": "./src/index.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@zerodev/sdk": "^4.1.5",
|
|
30
|
+
"@dynamic-labs/sdk-api": "0.0.307",
|
|
31
|
+
"@dynamic-labs/types": "1.0.0-alpha.1",
|
|
32
|
+
"@dynamic-labs/utils": "1.0.0-alpha.1",
|
|
33
|
+
"@dynamic-labs/viem-utils": "1.0.0-alpha.1",
|
|
34
|
+
"@dynamic-labs/wallet-book": "1.0.0-alpha.1",
|
|
35
|
+
"@dynamic-labs/wallet-connector-core": "1.0.0-alpha.1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"viem": "^1.1.0"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
|
+
var sdk = require('@zerodev/sdk');
|
|
7
|
+
var viem = require('viem');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
+
var viemUtils = require('@dynamic-labs/viem-utils');
|
|
10
|
+
var utils = require('@dynamic-labs/utils');
|
|
11
|
+
|
|
12
|
+
class ZeroDevConnector extends walletConnectorCore.WalletConnectorBase {
|
|
13
|
+
constructor(opts) {
|
|
14
|
+
var _a;
|
|
15
|
+
super(opts);
|
|
16
|
+
this.connectedChain = 'EVM';
|
|
17
|
+
this.supportedChains = ['ETH', 'EVM'];
|
|
18
|
+
this.name = 'ZeroDev';
|
|
19
|
+
const zeroDevProjectId = (_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.clientId;
|
|
20
|
+
if (!zeroDevProjectId) {
|
|
21
|
+
throw new Error('Missing ZeroDev project ID provided. Add your ZeroDev project id to your project configuration via the Dynamic Labs dashboard.');
|
|
22
|
+
}
|
|
23
|
+
this.projectId = zeroDevProjectId;
|
|
24
|
+
this._walletUiUtils = opts.walletUiUtils;
|
|
25
|
+
this.evmNetworks = utils.parseEvmNetworks(opts.evmNetworks);
|
|
26
|
+
}
|
|
27
|
+
setEoaConnector(connector) {
|
|
28
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
this.eoaConnector = connector;
|
|
30
|
+
const signer = yield this.eoaConnector.getSigner();
|
|
31
|
+
this.zeroDevProvider = new sdk.ECDSAProvider({
|
|
32
|
+
owner: sdk.convertWalletClientToAccountSigner(signer),
|
|
33
|
+
projectId: this.projectId,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
fetchPublicAddress() {
|
|
38
|
+
var _a;
|
|
39
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return (_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
getConnectedAccounts() {
|
|
44
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return this.zeroDevProvider
|
|
46
|
+
? [yield this.zeroDevProvider.getAddress()]
|
|
47
|
+
: [];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getNetwork() {
|
|
51
|
+
var _a;
|
|
52
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return (_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.rpcClient.chain.id;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
getPublicClient() {
|
|
57
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const provider = this.zeroDevProvider;
|
|
59
|
+
if (!provider)
|
|
60
|
+
throw new utils.DynamicError('No provider');
|
|
61
|
+
return provider.rpcClient;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getSigner() {
|
|
65
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const provider = this.zeroDevProvider;
|
|
67
|
+
if (!provider)
|
|
68
|
+
throw new utils.DynamicError('No provider');
|
|
69
|
+
const transport = viemUtils.confirmationTransport({
|
|
70
|
+
connector: this,
|
|
71
|
+
onPersonalSign: ({ message }) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
this._walletUiUtils.disabledConfirmationOnce();
|
|
73
|
+
return provider.signMessage(message);
|
|
74
|
+
}),
|
|
75
|
+
onSendTransaction: ({ transaction }) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
this._walletUiUtils.disabledConfirmationOnce();
|
|
77
|
+
const response = yield provider.sendTransaction(viemUtils.unFormatTransaction(transaction));
|
|
78
|
+
return response;
|
|
79
|
+
}),
|
|
80
|
+
onSignTypedData: ({ args }) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
this._walletUiUtils.disabledConfirmationOnce();
|
|
82
|
+
return provider.signTypedData(args);
|
|
83
|
+
}),
|
|
84
|
+
provider: provider.rpcClient,
|
|
85
|
+
transport: viem.custom(provider),
|
|
86
|
+
walletUiUtils: this._walletUiUtils,
|
|
87
|
+
});
|
|
88
|
+
const address = yield provider.getAddress();
|
|
89
|
+
const walletClient = viem.createWalletClient({
|
|
90
|
+
account: address,
|
|
91
|
+
transport,
|
|
92
|
+
});
|
|
93
|
+
return walletClient;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
isGasSponsored(transaction) {
|
|
97
|
+
var _a;
|
|
98
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const userOperation = {
|
|
100
|
+
data: transaction.data ? transaction.data : '0x',
|
|
101
|
+
target: transaction.to,
|
|
102
|
+
value: viem.isHex(transaction.value)
|
|
103
|
+
? viem.fromHex(transaction.value, 'bigint')
|
|
104
|
+
: transaction.value,
|
|
105
|
+
};
|
|
106
|
+
const result = yield ((_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.buildUserOperation(userOperation));
|
|
107
|
+
if (!result)
|
|
108
|
+
return false;
|
|
109
|
+
return result.paymasterAndData !== '0x';
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
getBalance() {
|
|
113
|
+
var _a;
|
|
114
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const rpcClient = yield ((_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.rpcClient);
|
|
116
|
+
if (!rpcClient)
|
|
117
|
+
throw new utils.DynamicError('No RPC client');
|
|
118
|
+
const address = yield this.fetchPublicAddress();
|
|
119
|
+
if (!address)
|
|
120
|
+
return;
|
|
121
|
+
return viem.formatEther(yield rpcClient.getBalance({ address: address }));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
signMessage(messageToSign) {
|
|
125
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const client = yield this.getSigner();
|
|
127
|
+
const account = yield this.fetchPublicAddress();
|
|
128
|
+
if (!account || !client)
|
|
129
|
+
return;
|
|
130
|
+
return client.signMessage({
|
|
131
|
+
account: account,
|
|
132
|
+
message: messageToSign,
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
exports.ZeroDevConnector = ZeroDevConnector;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ECDSAProvider } from '@zerodev/sdk';
|
|
2
|
+
import { PublicClient, RpcTransactionRequest, WalletClient } from 'viem';
|
|
3
|
+
import { Provider, ProviderEnum } from '@dynamic-labs/sdk-api';
|
|
4
|
+
import { Chain, WalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
6
|
+
import { EvmNetwork, GenericNetwork, WalletUiUtils } from '@dynamic-labs/types';
|
|
7
|
+
type ZeroDevConnectorProps = {
|
|
8
|
+
apiProviders: {
|
|
9
|
+
[key in ProviderEnum]?: Provider;
|
|
10
|
+
};
|
|
11
|
+
evmNetworks: GenericNetwork[];
|
|
12
|
+
walletBook: WalletBookSchema;
|
|
13
|
+
walletUiUtils: WalletUiUtils<WalletConnector>;
|
|
14
|
+
};
|
|
15
|
+
export declare class ZeroDevConnector extends WalletConnectorBase {
|
|
16
|
+
projectId: string;
|
|
17
|
+
zeroDevProvider: ECDSAProvider | undefined;
|
|
18
|
+
eoaConnector: WalletConnector | undefined;
|
|
19
|
+
connectedChain: Chain;
|
|
20
|
+
supportedChains: Chain[];
|
|
21
|
+
evmNetworks: EvmNetwork[];
|
|
22
|
+
name: string;
|
|
23
|
+
private _walletUiUtils;
|
|
24
|
+
constructor(opts: ZeroDevConnectorProps);
|
|
25
|
+
setEoaConnector(connector: WalletConnector): Promise<void>;
|
|
26
|
+
fetchPublicAddress(): Promise<string | undefined>;
|
|
27
|
+
getConnectedAccounts(): Promise<string[]>;
|
|
28
|
+
getNetwork(): Promise<number | undefined>;
|
|
29
|
+
getPublicClient(): Promise<void | PublicClient | undefined>;
|
|
30
|
+
getSigner(): Promise<WalletClient | undefined>;
|
|
31
|
+
isGasSponsored(transaction: RpcTransactionRequest): Promise<boolean>;
|
|
32
|
+
getBalance(): Promise<string | undefined>;
|
|
33
|
+
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
+
import { ECDSAProvider, convertWalletClientToAccountSigner } from '@zerodev/sdk';
|
|
3
|
+
import { custom, createWalletClient, isHex, fromHex, formatEther } from 'viem';
|
|
4
|
+
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { confirmationTransport, unFormatTransaction } from '@dynamic-labs/viem-utils';
|
|
6
|
+
import { parseEvmNetworks, DynamicError } from '@dynamic-labs/utils';
|
|
7
|
+
|
|
8
|
+
class ZeroDevConnector extends WalletConnectorBase {
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
var _a;
|
|
11
|
+
super(opts);
|
|
12
|
+
this.connectedChain = 'EVM';
|
|
13
|
+
this.supportedChains = ['ETH', 'EVM'];
|
|
14
|
+
this.name = 'ZeroDev';
|
|
15
|
+
const zeroDevProjectId = (_a = opts.apiProviders.zerodev) === null || _a === void 0 ? void 0 : _a.clientId;
|
|
16
|
+
if (!zeroDevProjectId) {
|
|
17
|
+
throw new Error('Missing ZeroDev project ID provided. Add your ZeroDev project id to your project configuration via the Dynamic Labs dashboard.');
|
|
18
|
+
}
|
|
19
|
+
this.projectId = zeroDevProjectId;
|
|
20
|
+
this._walletUiUtils = opts.walletUiUtils;
|
|
21
|
+
this.evmNetworks = parseEvmNetworks(opts.evmNetworks);
|
|
22
|
+
}
|
|
23
|
+
setEoaConnector(connector) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
this.eoaConnector = connector;
|
|
26
|
+
const signer = yield this.eoaConnector.getSigner();
|
|
27
|
+
this.zeroDevProvider = new ECDSAProvider({
|
|
28
|
+
owner: convertWalletClientToAccountSigner(signer),
|
|
29
|
+
projectId: this.projectId,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
fetchPublicAddress() {
|
|
34
|
+
var _a;
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
return (_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getConnectedAccounts() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return this.zeroDevProvider
|
|
42
|
+
? [yield this.zeroDevProvider.getAddress()]
|
|
43
|
+
: [];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getNetwork() {
|
|
47
|
+
var _a;
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
return (_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.rpcClient.chain.id;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
getPublicClient() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const provider = this.zeroDevProvider;
|
|
55
|
+
if (!provider)
|
|
56
|
+
throw new DynamicError('No provider');
|
|
57
|
+
return provider.rpcClient;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getSigner() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const provider = this.zeroDevProvider;
|
|
63
|
+
if (!provider)
|
|
64
|
+
throw new DynamicError('No provider');
|
|
65
|
+
const transport = confirmationTransport({
|
|
66
|
+
connector: this,
|
|
67
|
+
onPersonalSign: ({ message }) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
this._walletUiUtils.disabledConfirmationOnce();
|
|
69
|
+
return provider.signMessage(message);
|
|
70
|
+
}),
|
|
71
|
+
onSendTransaction: ({ transaction }) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
this._walletUiUtils.disabledConfirmationOnce();
|
|
73
|
+
const response = yield provider.sendTransaction(unFormatTransaction(transaction));
|
|
74
|
+
return response;
|
|
75
|
+
}),
|
|
76
|
+
onSignTypedData: ({ args }) => __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
this._walletUiUtils.disabledConfirmationOnce();
|
|
78
|
+
return provider.signTypedData(args);
|
|
79
|
+
}),
|
|
80
|
+
provider: provider.rpcClient,
|
|
81
|
+
transport: custom(provider),
|
|
82
|
+
walletUiUtils: this._walletUiUtils,
|
|
83
|
+
});
|
|
84
|
+
const address = yield provider.getAddress();
|
|
85
|
+
const walletClient = createWalletClient({
|
|
86
|
+
account: address,
|
|
87
|
+
transport,
|
|
88
|
+
});
|
|
89
|
+
return walletClient;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
isGasSponsored(transaction) {
|
|
93
|
+
var _a;
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const userOperation = {
|
|
96
|
+
data: transaction.data ? transaction.data : '0x',
|
|
97
|
+
target: transaction.to,
|
|
98
|
+
value: isHex(transaction.value)
|
|
99
|
+
? fromHex(transaction.value, 'bigint')
|
|
100
|
+
: transaction.value,
|
|
101
|
+
};
|
|
102
|
+
const result = yield ((_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.buildUserOperation(userOperation));
|
|
103
|
+
if (!result)
|
|
104
|
+
return false;
|
|
105
|
+
return result.paymasterAndData !== '0x';
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
getBalance() {
|
|
109
|
+
var _a;
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const rpcClient = yield ((_a = this.zeroDevProvider) === null || _a === void 0 ? void 0 : _a.rpcClient);
|
|
112
|
+
if (!rpcClient)
|
|
113
|
+
throw new DynamicError('No RPC client');
|
|
114
|
+
const address = yield this.fetchPublicAddress();
|
|
115
|
+
if (!address)
|
|
116
|
+
return;
|
|
117
|
+
return formatEther(yield rpcClient.getBalance({ address: address }));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
signMessage(messageToSign) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const client = yield this.getSigner();
|
|
123
|
+
const account = yield this.fetchPublicAddress();
|
|
124
|
+
if (!account || !client)
|
|
125
|
+
return;
|
|
126
|
+
return client.signMessage({
|
|
127
|
+
account: account,
|
|
128
|
+
message: messageToSign,
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { ZeroDevConnector };
|
package/src/index.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var ZeroDevConnector = require('./ZeroDevConnector.cjs');
|
|
6
|
+
var ethereumAa = require('./ethereum-aa.cjs');
|
|
7
|
+
|
|
8
|
+
const EthereumSmartWalletConnectors = (props) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const connectors = [];
|
|
11
|
+
if ((_a = props.apiProviders) === null || _a === void 0 ? void 0 : _a.zerodev) {
|
|
12
|
+
connectors.push(ZeroDevConnector.ZeroDevConnector);
|
|
13
|
+
}
|
|
14
|
+
return connectors;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.EthereumAaConnector = ethereumAa.EthereumAaConnector;
|
|
18
|
+
exports.EthereumSmartWalletConnectors = EthereumSmartWalletConnectors;
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ZeroDevConnector } from './ZeroDevConnector.js';
|
|
2
|
+
export { EthereumAaConnector } from './ethereum-aa.js';
|
|
3
|
+
|
|
4
|
+
const EthereumSmartWalletConnectors = (props) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const connectors = [];
|
|
7
|
+
if ((_a = props.apiProviders) === null || _a === void 0 ? void 0 : _a.zerodev) {
|
|
8
|
+
connectors.push(ZeroDevConnector);
|
|
9
|
+
}
|
|
10
|
+
return connectors;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { EthereumSmartWalletConnectors };
|