@nucypher/shared 0.6.0-alpha.2 → 0.6.0-dev.viem
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/adapters.d.ts +25 -0
- package/dist/cjs/adapters.js +44 -0
- package/dist/cjs/adapters.js.map +1 -0
- package/dist/cjs/contracts/agents/coordinator.d.ts +3 -3
- package/dist/cjs/contracts/agents/coordinator.js +6 -6
- package/dist/cjs/contracts/agents/coordinator.js.map +1 -1
- package/dist/cjs/contracts/agents/global-allow-list.d.ts +2 -2
- package/dist/cjs/contracts/agents/global-allow-list.js +4 -4
- package/dist/cjs/contracts/agents/global-allow-list.js.map +1 -1
- package/dist/cjs/contracts/agents/index.d.ts +3 -4
- package/dist/cjs/contracts/agents/index.js +3 -4
- package/dist/cjs/contracts/agents/index.js.map +1 -1
- package/dist/cjs/contracts/agents/subscription-manager.d.ts +2 -2
- package/dist/cjs/contracts/agents/subscription-manager.js +4 -4
- package/dist/cjs/contracts/agents/subscription-manager.js.map +1 -1
- package/dist/cjs/contracts/ethers-typechain/Coordinator.d.ts +1 -1
- package/dist/cjs/contracts/ethers-typechain/GlobalAllowList.d.ts +1 -1
- package/dist/cjs/contracts/ethers-typechain/SubscriptionManager.d.ts +1 -1
- package/dist/cjs/contracts/ethers-typechain/factories/Coordinator__factory.d.ts +1 -1
- package/dist/cjs/contracts/ethers-typechain/factories/GlobalAllowList__factory.d.ts +1 -1
- package/dist/cjs/contracts/ethers-typechain/factories/SubscriptionManager__factory.d.ts +1 -1
- package/dist/cjs/contracts/ethers-typechain/factories/index.d.ts +3 -4
- package/dist/cjs/contracts/ethers-typechain/factories/index.js +7 -9
- package/dist/cjs/contracts/ethers-typechain/factories/index.js.map +1 -1
- package/dist/cjs/contracts/ethers-typechain/index.d.ts +7 -9
- package/dist/cjs/contracts/ethers-typechain/index.js +8 -10
- package/dist/cjs/contracts/ethers-typechain/index.js.map +1 -1
- package/dist/cjs/contracts/index.d.ts +2 -2
- package/dist/cjs/contracts/index.js +2 -2
- package/dist/cjs/contracts/index.js.map +1 -1
- package/dist/cjs/domain.d.ts +43 -0
- package/dist/cjs/domain.js +49 -0
- package/dist/cjs/domain.js.map +1 -0
- package/dist/cjs/index.d.ts +10 -6
- package/dist/cjs/index.js +9 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/porter.d.ts +1 -13
- package/dist/cjs/porter.js +10 -66
- package/dist/cjs/porter.js.map +1 -1
- package/dist/cjs/schemas.d.ts +0 -1
- package/dist/cjs/schemas.js +1 -14
- package/dist/cjs/schemas.js.map +1 -1
- package/dist/cjs/taco-signer.d.ts +19 -0
- package/dist/cjs/{contracts/ethers-typechain/SigningCoordinator.js → taco-signer.js} +1 -1
- package/dist/cjs/taco-signer.js.map +1 -0
- package/dist/cjs/types.d.ts +9 -44
- package/dist/cjs/types.js +0 -63
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/viem/ethers-adapter.d.ts +19 -0
- package/dist/cjs/viem/ethers-adapter.js +103 -0
- package/dist/cjs/viem/ethers-adapter.js.map +1 -0
- package/dist/cjs/viem/index.d.ts +2 -0
- package/dist/cjs/viem/index.js +18 -0
- package/dist/cjs/viem/index.js.map +1 -0
- package/dist/cjs/viem/signer-adapter.d.ts +13 -0
- package/dist/cjs/viem/signer-adapter.js +54 -0
- package/dist/cjs/viem/signer-adapter.js.map +1 -0
- package/dist/cjs/viem/type-guards.d.ts +20 -0
- package/dist/cjs/viem/type-guards.js +49 -0
- package/dist/cjs/viem/type-guards.js.map +1 -0
- package/dist/cjs/viem/types.d.ts +53 -0
- package/dist/cjs/viem/types.js +21 -0
- package/dist/cjs/viem/types.js.map +1 -0
- package/dist/cjs/web3.js +2 -2
- package/dist/cjs/web3.js.map +1 -1
- package/dist/es/adapters.d.ts +25 -0
- package/dist/es/adapters.js +40 -0
- package/dist/es/adapters.js.map +1 -0
- package/dist/es/contracts/agents/coordinator.d.ts +3 -3
- package/dist/es/contracts/agents/coordinator.js +3 -3
- package/dist/es/contracts/agents/coordinator.js.map +1 -1
- package/dist/es/contracts/agents/global-allow-list.d.ts +2 -2
- package/dist/es/contracts/agents/global-allow-list.js +2 -2
- package/dist/es/contracts/agents/global-allow-list.js.map +1 -1
- package/dist/es/contracts/agents/index.d.ts +3 -4
- package/dist/es/contracts/agents/index.js +3 -4
- package/dist/es/contracts/agents/index.js.map +1 -1
- package/dist/es/contracts/agents/subscription-manager.d.ts +2 -2
- package/dist/es/contracts/agents/subscription-manager.js +2 -2
- package/dist/es/contracts/agents/subscription-manager.js.map +1 -1
- package/dist/es/contracts/ethers-typechain/Coordinator.d.ts +1 -1
- package/dist/es/contracts/ethers-typechain/GlobalAllowList.d.ts +1 -1
- package/dist/es/contracts/ethers-typechain/SubscriptionManager.d.ts +1 -1
- package/dist/es/contracts/ethers-typechain/factories/Coordinator__factory.d.ts +1 -1
- package/dist/es/contracts/ethers-typechain/factories/GlobalAllowList__factory.d.ts +1 -1
- package/dist/es/contracts/ethers-typechain/factories/SubscriptionManager__factory.d.ts +1 -1
- package/dist/es/contracts/ethers-typechain/factories/index.d.ts +3 -4
- package/dist/es/contracts/ethers-typechain/factories/index.js +3 -4
- package/dist/es/contracts/ethers-typechain/factories/index.js.map +1 -1
- package/dist/es/contracts/ethers-typechain/index.d.ts +7 -9
- package/dist/es/contracts/ethers-typechain/index.js +4 -5
- package/dist/es/contracts/ethers-typechain/index.js.map +1 -1
- package/dist/es/contracts/index.d.ts +2 -2
- package/dist/es/contracts/index.js +2 -2
- package/dist/es/contracts/index.js.map +1 -1
- package/dist/es/domain.d.ts +43 -0
- package/dist/es/domain.js +46 -0
- package/dist/es/domain.js.map +1 -0
- package/dist/es/index.d.ts +10 -6
- package/dist/es/index.js +9 -6
- package/dist/es/index.js.map +1 -1
- package/dist/es/package.json +3 -0
- package/dist/es/porter.d.ts +1 -13
- package/dist/es/porter.js +1 -57
- package/dist/es/porter.js.map +1 -1
- package/dist/es/schemas.d.ts +0 -1
- package/dist/es/schemas.js +0 -13
- package/dist/es/schemas.js.map +1 -1
- package/dist/es/taco-signer.d.ts +19 -0
- package/dist/es/taco-signer.js +2 -0
- package/dist/es/taco-signer.js.map +1 -0
- package/dist/es/types.d.ts +9 -44
- package/dist/es/types.js +1 -60
- package/dist/es/types.js.map +1 -1
- package/dist/es/viem/ethers-adapter.d.ts +19 -0
- package/dist/es/viem/ethers-adapter.js +100 -0
- package/dist/es/viem/ethers-adapter.js.map +1 -0
- package/dist/es/viem/index.d.ts +2 -0
- package/dist/es/viem/index.js +2 -0
- package/dist/es/viem/index.js.map +1 -0
- package/dist/es/viem/signer-adapter.d.ts +13 -0
- package/dist/es/viem/signer-adapter.js +50 -0
- package/dist/es/viem/signer-adapter.js.map +1 -0
- package/dist/es/viem/type-guards.d.ts +20 -0
- package/dist/es/viem/type-guards.js +45 -0
- package/dist/es/viem/type-guards.js.map +1 -0
- package/dist/es/viem/types.d.ts +53 -0
- package/dist/es/viem/types.js +20 -0
- package/dist/es/viem/types.js.map +1 -0
- package/dist/es/web3.js +1 -1
- package/dist/es/web3.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.es.tsbuildinfo +1 -1
- package/package.json +19 -6
- package/dist/cjs/contracts/agents/signing-coordinator.d.ts +0 -16
- package/dist/cjs/contracts/agents/signing-coordinator.js +0 -42
- package/dist/cjs/contracts/agents/signing-coordinator.js.map +0 -1
- package/dist/cjs/contracts/agents/signingCoordinator.d.ts +0 -14
- package/dist/cjs/contracts/agents/signingCoordinator.js +0 -32
- package/dist/cjs/contracts/agents/signingCoordinator.js.map +0 -1
- package/dist/cjs/contracts/ethers-typechain/SigningCoordinator.d.ts +0 -787
- package/dist/cjs/contracts/ethers-typechain/SigningCoordinator.js.map +0 -1
- package/dist/cjs/contracts/ethers-typechain/factories/SigningCoordinator__factory.d.ts +0 -939
- package/dist/cjs/contracts/ethers-typechain/factories/SigningCoordinator__factory.js +0 -1227
- package/dist/cjs/contracts/ethers-typechain/factories/SigningCoordinator__factory.js.map +0 -1
- package/dist/es/contracts/agents/signing-coordinator.d.ts +0 -16
- package/dist/es/contracts/agents/signing-coordinator.js +0 -38
- package/dist/es/contracts/agents/signing-coordinator.js.map +0 -1
- package/dist/es/contracts/agents/signingCoordinator.d.ts +0 -14
- package/dist/es/contracts/agents/signingCoordinator.js +0 -28
- package/dist/es/contracts/agents/signingCoordinator.js.map +0 -1
- package/dist/es/contracts/ethers-typechain/SigningCoordinator.d.ts +0 -787
- package/dist/es/contracts/ethers-typechain/SigningCoordinator.js +0 -2
- package/dist/es/contracts/ethers-typechain/SigningCoordinator.js.map +0 -1
- package/dist/es/contracts/ethers-typechain/factories/SigningCoordinator__factory.d.ts +0 -939
- package/dist/es/contracts/ethers-typechain/factories/SigningCoordinator__factory.js +0 -1223
- package/dist/es/contracts/ethers-typechain/factories/SigningCoordinator__factory.js.map +0 -1
package/dist/cjs/porter.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CapsuleFrag, EncryptedThresholdDecryptionRequest, EncryptedThresholdDecryptionResponse, PublicKey, RetrievalKit, TreasureMap } from '@nucypher/nucypher-core';
|
|
2
2
|
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
3
|
-
import { ChecksumAddress, HexEncodedBytes } from './types';
|
|
3
|
+
import { ChecksumAddress, HexEncodedBytes } from './types.js';
|
|
4
4
|
declare const defaultPorterUri: Record<string, string>;
|
|
5
5
|
export type Domain = keyof typeof defaultPorterUri;
|
|
6
6
|
export type PorterURISourceResponse = Record<string, string[]>;
|
|
@@ -32,17 +32,6 @@ export type TacoDecryptResult = {
|
|
|
32
32
|
encryptedResponses: Record<string, EncryptedThresholdDecryptionResponse>;
|
|
33
33
|
errors: Record<string, string>;
|
|
34
34
|
};
|
|
35
|
-
export type TacoSignature = {
|
|
36
|
-
messageHash: string;
|
|
37
|
-
signature: string;
|
|
38
|
-
signerAddress: string;
|
|
39
|
-
};
|
|
40
|
-
export type TacoSignResult = {
|
|
41
|
-
signingResults: {
|
|
42
|
-
[ursulaAddress: string]: TacoSignature;
|
|
43
|
-
};
|
|
44
|
-
errors: Record<string, string>;
|
|
45
|
-
};
|
|
46
35
|
export declare class PorterClient {
|
|
47
36
|
readonly porterUrls: URL[];
|
|
48
37
|
constructor(porterUris: string | string[]);
|
|
@@ -50,6 +39,5 @@ export declare class PorterClient {
|
|
|
50
39
|
getUrsulas(quantity: number, excludeUrsulas?: readonly ChecksumAddress[], includeUrsulas?: readonly ChecksumAddress[]): Promise<readonly Ursula[]>;
|
|
51
40
|
retrieveCFrags(treasureMap: TreasureMap, retrievalKits: readonly RetrievalKit[], aliceVerifyingKey: PublicKey, bobEncryptingKey: PublicKey, bobVerifyingKey: PublicKey, conditionContextJSON?: string | undefined): Promise<readonly RetrieveCFragsResult[]>;
|
|
52
41
|
tacoDecrypt(encryptedRequests: Record<string, EncryptedThresholdDecryptionRequest>, threshold: number): Promise<TacoDecryptResult>;
|
|
53
|
-
signUserOp(signingRequests: Record<string, string>, threshold: number): Promise<TacoSignResult>;
|
|
54
42
|
}
|
|
55
43
|
export {};
|
package/dist/cjs/porter.js
CHANGED
|
@@ -40,7 +40,7 @@ exports.PorterClient = exports.getPorterUrisFromSource = exports.getPorterUris =
|
|
|
40
40
|
const nucypher_core_1 = require("@nucypher/nucypher-core");
|
|
41
41
|
const axios_1 = __importStar(require("axios"));
|
|
42
42
|
const qs_1 = __importDefault(require("qs"));
|
|
43
|
-
const
|
|
43
|
+
const utils_js_1 = require("./utils.js");
|
|
44
44
|
const defaultPorterUri = {
|
|
45
45
|
mainnet: 'https://porter.nucypher.io',
|
|
46
46
|
tapir: 'https://porter-tapir.nucypher.io',
|
|
@@ -85,23 +85,6 @@ const getPorterUrisFromSource = async (domain) => {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
exports.getPorterUrisFromSource = getPorterUrisFromSource;
|
|
88
|
-
function decodeSignature(signerAddress, signatureB64) {
|
|
89
|
-
try {
|
|
90
|
-
const decodedData = JSON.parse(new TextDecoder().decode((0, utils_1.fromBase64)(signatureB64)));
|
|
91
|
-
return {
|
|
92
|
-
result: {
|
|
93
|
-
messageHash: decodedData.message_hash,
|
|
94
|
-
signature: decodedData.signature,
|
|
95
|
-
signerAddress,
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
return {
|
|
101
|
-
error: `Failed to decode signature: ${error}`,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
88
|
class PorterClient {
|
|
106
89
|
porterUrls;
|
|
107
90
|
constructor(porterUris) {
|
|
@@ -124,17 +107,6 @@ class PorterClient {
|
|
|
124
107
|
}
|
|
125
108
|
}
|
|
126
109
|
catch (e) {
|
|
127
|
-
const errorDetails = {
|
|
128
|
-
url: porterUrl.toString(),
|
|
129
|
-
method: config.method,
|
|
130
|
-
requestData: config.data,
|
|
131
|
-
};
|
|
132
|
-
if (axios_1.default.isAxiosError(e)) {
|
|
133
|
-
errorDetails.status = e.response?.status;
|
|
134
|
-
errorDetails.statusText = e.response?.statusText;
|
|
135
|
-
errorDetails.data = e.response?.data;
|
|
136
|
-
}
|
|
137
|
-
console.error('Porter request failed:', errorDetails);
|
|
138
110
|
lastError = e;
|
|
139
111
|
continue;
|
|
140
112
|
}
|
|
@@ -161,16 +133,16 @@ class PorterClient {
|
|
|
161
133
|
return resp.data.result.ursulas.map((u) => ({
|
|
162
134
|
checksumAddress: u.checksum_address,
|
|
163
135
|
uri: u.uri,
|
|
164
|
-
encryptingKey: nucypher_core_1.PublicKey.fromCompressedBytes((0,
|
|
136
|
+
encryptingKey: nucypher_core_1.PublicKey.fromCompressedBytes((0, utils_js_1.fromHexString)(u.encrypting_key)),
|
|
165
137
|
}));
|
|
166
138
|
}
|
|
167
139
|
async retrieveCFrags(treasureMap, retrievalKits, aliceVerifyingKey, bobEncryptingKey, bobVerifyingKey, conditionContextJSON = undefined) {
|
|
168
140
|
const data = {
|
|
169
|
-
treasure_map: (0,
|
|
170
|
-
retrieval_kits: retrievalKits.map((rk) => (0,
|
|
171
|
-
alice_verifying_key: (0,
|
|
172
|
-
bob_encrypting_key: (0,
|
|
173
|
-
bob_verifying_key: (0,
|
|
141
|
+
treasure_map: (0, utils_js_1.toBase64)(treasureMap.toBytes()),
|
|
142
|
+
retrieval_kits: retrievalKits.map((rk) => (0, utils_js_1.toBase64)(rk.toBytes())),
|
|
143
|
+
alice_verifying_key: (0, utils_js_1.toHexString)(aliceVerifyingKey.toCompressedBytes()),
|
|
144
|
+
bob_encrypting_key: (0, utils_js_1.toHexString)(bobEncryptingKey.toCompressedBytes()),
|
|
145
|
+
bob_verifying_key: (0, utils_js_1.toHexString)(bobVerifyingKey.toCompressedBytes()),
|
|
174
146
|
context: conditionContextJSON,
|
|
175
147
|
};
|
|
176
148
|
const resp = await this.tryAndCall({
|
|
@@ -181,7 +153,7 @@ class PorterClient {
|
|
|
181
153
|
return resp.data.result.retrieval_results.map(({ cfrags, errors }) => {
|
|
182
154
|
const parsed = Object.keys(cfrags).map((address) => [
|
|
183
155
|
address,
|
|
184
|
-
nucypher_core_1.CapsuleFrag.fromBytes((0,
|
|
156
|
+
nucypher_core_1.CapsuleFrag.fromBytes((0, utils_js_1.fromBase64)(cfrags[address])),
|
|
185
157
|
]);
|
|
186
158
|
const cFrags = Object.fromEntries(parsed);
|
|
187
159
|
return { cFrags, errors };
|
|
@@ -191,7 +163,7 @@ class PorterClient {
|
|
|
191
163
|
const data = {
|
|
192
164
|
encrypted_decryption_requests: Object.fromEntries(Object.entries(encryptedRequests).map(([ursula, encryptedRequest]) => [
|
|
193
165
|
ursula,
|
|
194
|
-
(0,
|
|
166
|
+
(0, utils_js_1.toBase64)(encryptedRequest.toBytes()),
|
|
195
167
|
])),
|
|
196
168
|
threshold,
|
|
197
169
|
};
|
|
@@ -202,40 +174,12 @@ class PorterClient {
|
|
|
202
174
|
});
|
|
203
175
|
const { encrypted_decryption_responses, errors } = resp.data.result.decryption_results;
|
|
204
176
|
const decryptionResponses = Object.entries(encrypted_decryption_responses).map(([address, encryptedResponseBase64]) => {
|
|
205
|
-
const encryptedResponse = nucypher_core_1.EncryptedThresholdDecryptionResponse.fromBytes((0,
|
|
177
|
+
const encryptedResponse = nucypher_core_1.EncryptedThresholdDecryptionResponse.fromBytes((0, utils_js_1.fromBase64)(encryptedResponseBase64));
|
|
206
178
|
return [address, encryptedResponse];
|
|
207
179
|
});
|
|
208
180
|
const encryptedResponses = Object.fromEntries(decryptionResponses);
|
|
209
181
|
return { encryptedResponses, errors };
|
|
210
182
|
}
|
|
211
|
-
async signUserOp(signingRequests, threshold) {
|
|
212
|
-
const data = {
|
|
213
|
-
signing_requests: signingRequests,
|
|
214
|
-
threshold: threshold,
|
|
215
|
-
};
|
|
216
|
-
const resp = await this.tryAndCall({
|
|
217
|
-
url: '/sign',
|
|
218
|
-
method: 'post',
|
|
219
|
-
data,
|
|
220
|
-
});
|
|
221
|
-
const { signatures, errors } = resp.data.result.signing_results;
|
|
222
|
-
const allErrors = { ...errors };
|
|
223
|
-
const signingResults = {};
|
|
224
|
-
for (const [ursulaAddress, [signerAddress, signatureB64]] of Object.entries(signatures || {})) {
|
|
225
|
-
const decoded = decodeSignature(signerAddress, signatureB64);
|
|
226
|
-
if (decoded.error) {
|
|
227
|
-
// issue with decoding signature, add to errors
|
|
228
|
-
allErrors[ursulaAddress] = decoded.error;
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
// Always include all decoded signatures in signingResults
|
|
232
|
-
signingResults[ursulaAddress] = decoded.result;
|
|
233
|
-
}
|
|
234
|
-
return {
|
|
235
|
-
signingResults,
|
|
236
|
-
errors: allErrors,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
183
|
}
|
|
240
184
|
exports.PorterClient = PorterClient;
|
|
241
185
|
//# sourceMappingURL=porter.js.map
|
package/dist/cjs/porter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"porter.js","sourceRoot":"","sources":["../../src/porter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAOiC;AACjC,+CAIe;AACf,4CAAoB;AAGpB,
|
|
1
|
+
{"version":3,"file":"porter.js","sourceRoot":"","sources":["../../src/porter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAOiC;AACjC,+CAIe;AACf,4CAAoB;AAGpB,yCAA8E;AAE9E,MAAM,gBAAgB,GAA2B;IAC/C,OAAO,EAAE,4BAA4B;IACrC,KAAK,EAAE,kCAAkC;IACzC,IAAI,EAAE,iCAAiC;CACxC,CAAC;AAEF,MAAM,eAAe,GACnB,uFAAuF,CAAC;AAK7E,QAAA,OAAO,GAA2B;IAC7C,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,SAAS;CACnB,CAAC;AAEK,MAAM,YAAY,GAAG,KAAK,EAAE,MAAc,EAAmB,EAAE;IACpE,OAAO,CAAC,MAAM,IAAA,qBAAa,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEK,MAAM,aAAa,GAAG,KAAK,EAAE,MAAc,EAAqB,EAAE;IACvE,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,MAAM,GAAG,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,2CAA2C,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,cAAc,GAAG,MAAM,IAAA,+BAAuB,EAAC,MAAM,CAAC,CAAC;IAC7D,QAAQ,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;IACjC,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IACL,CAAC;IAEM,KAAK,CAAC,WAAW,CACtB,iBAAsE,EACtE,SAAiB;QAEjB,MAAM,IAAI,GAA2B;YACnC,6BAA6B,EAAE,MAAM,CAAC,WAAW,CAC/C,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC;gBACpE,MAAM;gBACN,IAAA,mBAAQ,EAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;aACrC,CAAC,CACH;YACD,SAAS;SACV,CAAC;QACF,MAAM,IAAI,GAA2C,MAAM,IAAI,CAAC,UAAU,CAAC;YACzE,GAAG,EAAE,UAAU;YACf,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,MAAM,EAAE,8BAA8B,EAAE,MAAM,EAAE,GAC9C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;QAEtC,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CACxC,8BAA8B,CAC/B,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,uBAAuB,CAAC,EAAE,EAAE;YAC3C,MAAM,iBAAiB,GAAG,oDAAoC,CAAC,SAAS,CACtE,IAAA,qBAAU,EAAC,uBAAuB,CAAC,CACpC,CAAC;YACF,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QACH,MAAM,kBAAkB,GAGpB,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;QAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IACxC,CAAC;CACF;AApID,oCAoIC"}
|
package/dist/cjs/schemas.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const EthAddressSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
3
|
-
export declare const EthAddressSchemaStrict: z.ZodEffects<z.ZodString, string, string>;
|
|
4
3
|
export declare const BlockIdentifierSchema: z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodEnum<["earliest", "finalized", "safe", "latest", "pending"]>]>;
|
package/dist/cjs/schemas.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlockIdentifierSchema = exports.
|
|
3
|
+
exports.BlockIdentifierSchema = exports.EthAddressSchema = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const isAddress = (address) => {
|
|
@@ -11,22 +11,9 @@ const isAddress = (address) => {
|
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
const isAddressStrict = (address) => {
|
|
15
|
-
try {
|
|
16
|
-
// Verify the address was checksummed to prevent passing an address that has a typo
|
|
17
|
-
return address === ethers_1.ethers.utils.getAddress(address);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
// If any error occurs during validation, fail the validation
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
14
|
exports.EthAddressSchema = zod_1.z
|
|
25
15
|
.string()
|
|
26
16
|
.refine(isAddress, { message: 'Invalid Ethereum address' });
|
|
27
|
-
exports.EthAddressSchemaStrict = zod_1.z.string().refine(isAddressStrict, {
|
|
28
|
-
message: 'Invalid Ethereum address - it must be valid and checksummed',
|
|
29
|
-
});
|
|
30
17
|
const BLOCK_HASH_REGEXP = new RegExp('^0x[a-fA-F0-9]{64}$');
|
|
31
18
|
const BlockNumber = zod_1.z.number().int().nonnegative();
|
|
32
19
|
const BlockHash = zod_1.z.string().regex(BLOCK_HASH_REGEXP, 'Invalid block hash');
|
package/dist/cjs/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src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
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TACo signer interface.
|
|
3
|
+
*
|
|
4
|
+
* This interface defines only the essential methods that TACo operations require:
|
|
5
|
+
* - `getAddress()`: Get the signer's address
|
|
6
|
+
* - `signMessage()`: Sign a message (string or bytes)
|
|
7
|
+
*
|
|
8
|
+
* Future signer adapters can implement this same minimal interface
|
|
9
|
+
*/
|
|
10
|
+
export interface TacoSigner {
|
|
11
|
+
/**
|
|
12
|
+
* Get the address of this signer
|
|
13
|
+
*/
|
|
14
|
+
getAddress(): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Sign a message
|
|
17
|
+
*/
|
|
18
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taco-signer.js","sourceRoot":"","sources":["../../src/taco-signer.ts"],"names":[],"mappings":""}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,47 +1,12 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { PublicClient, SignerAccount } from './viem/types.js';
|
|
1
3
|
export type ChecksumAddress = `0x${string}`;
|
|
2
4
|
export type HexEncodedBytes = string;
|
|
3
5
|
export type Base64EncodedBytes = string;
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
verificationGasLimit: number;
|
|
12
|
-
preVerificationGas: number;
|
|
13
|
-
maxFeePerGas: number;
|
|
14
|
-
maxPriorityFeePerGas: number;
|
|
15
|
-
paymaster: string;
|
|
16
|
-
paymasterVerificationGasLimit: number;
|
|
17
|
-
paymasterPostOpGasLimit: number;
|
|
18
|
-
paymasterData: string;
|
|
19
|
-
signature: string;
|
|
20
|
-
};
|
|
21
|
-
export declare class UserOperationSignatureRequest {
|
|
22
|
-
private userOp;
|
|
23
|
-
private aaVersion;
|
|
24
|
-
private cohortId;
|
|
25
|
-
private chainId;
|
|
26
|
-
private context;
|
|
27
|
-
private signatureType;
|
|
28
|
-
constructor(userOp: ReturnType<typeof convertUserOperationToPython>, aaVersion: string, cohortId: number, chainId: number, context?: unknown, signatureType?: string);
|
|
29
|
-
toBytes(): Uint8Array;
|
|
30
|
-
}
|
|
31
|
-
export declare function convertUserOperationToPython(userOp: UserOperation): {
|
|
32
|
-
sender: string | null;
|
|
33
|
-
nonce: number;
|
|
34
|
-
factory: string | null;
|
|
35
|
-
factory_data: string;
|
|
36
|
-
call_data: string;
|
|
37
|
-
call_gas_limit: number;
|
|
38
|
-
verification_gas_limit: number;
|
|
39
|
-
pre_verification_gas: number;
|
|
40
|
-
max_fee_per_gas: number;
|
|
41
|
-
max_priority_fee_per_gas: number;
|
|
42
|
-
paymaster: string | null;
|
|
43
|
-
paymaster_verification_gas_limit: number;
|
|
44
|
-
paymaster_post_op_gas_limit: number;
|
|
45
|
-
paymaster_data: string;
|
|
46
|
-
signature: string;
|
|
47
|
-
};
|
|
6
|
+
export type ProviderLike = ethers.providers.Provider | PublicClient;
|
|
7
|
+
/**
|
|
8
|
+
* Signer-like union for TACo operations.
|
|
9
|
+
*
|
|
10
|
+
* Accepts either ethers Signer or viem SignerAccount (LocalAccount or WalletClient)
|
|
11
|
+
*/
|
|
12
|
+
export type SignerLike = ethers.Signer | SignerAccount;
|
package/dist/cjs/types.js
CHANGED
|
@@ -1,66 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserOperationSignatureRequest = void 0;
|
|
4
|
-
exports.convertUserOperationToPython = convertUserOperationToPython;
|
|
5
|
-
const ethers_1 = require("ethers");
|
|
6
|
-
class UserOperationSignatureRequest {
|
|
7
|
-
userOp;
|
|
8
|
-
aaVersion;
|
|
9
|
-
cohortId;
|
|
10
|
-
chainId;
|
|
11
|
-
context;
|
|
12
|
-
signatureType;
|
|
13
|
-
constructor(userOp, aaVersion, cohortId, chainId, context = {}, signatureType = 'userop') {
|
|
14
|
-
this.userOp = userOp;
|
|
15
|
-
this.aaVersion = aaVersion;
|
|
16
|
-
this.cohortId = cohortId;
|
|
17
|
-
this.chainId = chainId;
|
|
18
|
-
this.context = context;
|
|
19
|
-
this.signatureType = signatureType;
|
|
20
|
-
}
|
|
21
|
-
toBytes() {
|
|
22
|
-
const data = {
|
|
23
|
-
user_op: JSON.stringify(this.userOp),
|
|
24
|
-
aa_version: this.aaVersion,
|
|
25
|
-
cohort_id: this.cohortId,
|
|
26
|
-
chain_id: this.chainId,
|
|
27
|
-
context: this.context,
|
|
28
|
-
signature_type: this.signatureType,
|
|
29
|
-
};
|
|
30
|
-
return new TextEncoder().encode(JSON.stringify(data));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.UserOperationSignatureRequest = UserOperationSignatureRequest;
|
|
34
|
-
function normalizeAddress(address) {
|
|
35
|
-
if (!address || address === '0x') {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
// Use ethers to get the checksummed address - this will throw on invalid addresses
|
|
40
|
-
return ethers_1.ethers.utils.getAddress(address);
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
// Re-throw the error to fail fast on invalid addresses
|
|
44
|
-
throw new Error(`Invalid address: ${address}. ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function convertUserOperationToPython(userOp) {
|
|
48
|
-
return {
|
|
49
|
-
sender: normalizeAddress(userOp.sender),
|
|
50
|
-
nonce: userOp.nonce,
|
|
51
|
-
factory: normalizeAddress(userOp.factory),
|
|
52
|
-
factory_data: userOp.factoryData || '0x',
|
|
53
|
-
call_data: userOp.callData || '0x',
|
|
54
|
-
call_gas_limit: userOp.callGasLimit,
|
|
55
|
-
verification_gas_limit: userOp.verificationGasLimit,
|
|
56
|
-
pre_verification_gas: userOp.preVerificationGas,
|
|
57
|
-
max_fee_per_gas: userOp.maxFeePerGas,
|
|
58
|
-
max_priority_fee_per_gas: userOp.maxPriorityFeePerGas,
|
|
59
|
-
paymaster: normalizeAddress(userOp.paymaster),
|
|
60
|
-
paymaster_verification_gas_limit: userOp.paymasterVerificationGasLimit,
|
|
61
|
-
paymaster_post_op_gas_limit: userOp.paymasterPostOpGasLimit,
|
|
62
|
-
paymaster_data: userOp.paymasterData || '0x',
|
|
63
|
-
signature: userOp.signature || '0x',
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
3
|
//# sourceMappingURL=types.js.map
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import type { PublicClient } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Viem to Ethers.js Adapter for Providers
|
|
5
|
+
*
|
|
6
|
+
* This adapter converts viem PublicClients to actual ethers.js Provider instances.
|
|
7
|
+
* Unlike the signer adapter which implements a minimal internal interface,
|
|
8
|
+
* this creates real ethers.providers.Provider objects that can be passed to
|
|
9
|
+
* third-party libraries expecting ethers.js providers.
|
|
10
|
+
*
|
|
11
|
+
* Key differences from signer adapter:
|
|
12
|
+
* - Creates ethers.providers.Provider instances
|
|
13
|
+
* - Currently handles only transport type: http
|
|
14
|
+
* - Required for external library compatibility
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Static method to directly convert client to provider (convenience method)
|
|
18
|
+
*/
|
|
19
|
+
export declare function viemClientToProvider(client: PublicClient): ethers.providers.Provider;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.viemClientToProvider = viemClientToProvider;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
/**
|
|
6
|
+
* Create ethers network object from viem chain
|
|
7
|
+
*/
|
|
8
|
+
function createNetworkish(chain) {
|
|
9
|
+
const networkish = {
|
|
10
|
+
chainId: chain.id,
|
|
11
|
+
name: chain.name,
|
|
12
|
+
};
|
|
13
|
+
// Add ENS registry address if available
|
|
14
|
+
// Note that it is not available by default in the last viem version. But also ENS is not used at taco for the user address (:useraddress).
|
|
15
|
+
// Therefore, no need to take any action if the ENS registry address is not available.
|
|
16
|
+
if (chain.contracts?.ensRegistry?.address) {
|
|
17
|
+
networkish.ensAddress = chain.contracts.ensRegistry.address;
|
|
18
|
+
}
|
|
19
|
+
return networkish;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Viem to Ethers.js Adapter for Providers
|
|
23
|
+
*
|
|
24
|
+
* This adapter converts viem PublicClients to actual ethers.js Provider instances.
|
|
25
|
+
* Unlike the signer adapter which implements a minimal internal interface,
|
|
26
|
+
* this creates real ethers.providers.Provider objects that can be passed to
|
|
27
|
+
* third-party libraries expecting ethers.js providers.
|
|
28
|
+
*
|
|
29
|
+
* Key differences from signer adapter:
|
|
30
|
+
* - Creates ethers.providers.Provider instances
|
|
31
|
+
* - Currently handles only transport type: http
|
|
32
|
+
* - Required for external library compatibility
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Static method to directly convert client to provider (convenience method)
|
|
36
|
+
*/
|
|
37
|
+
function viemClientToProvider(client) {
|
|
38
|
+
const { chain, transport } = client;
|
|
39
|
+
let networkish;
|
|
40
|
+
if (chain) {
|
|
41
|
+
networkish = createNetworkish(chain);
|
|
42
|
+
}
|
|
43
|
+
// Note: We read minimal, commonly-present properties from transport.
|
|
44
|
+
// viem's transport internals are not a public API and may change.
|
|
45
|
+
// Also the we are taking only the first transport available.
|
|
46
|
+
// This adapter focuses on best-effort extraction of an RPC URL or EIP-1193 provider.
|
|
47
|
+
// fallback transport (multiple RPC endpoints)
|
|
48
|
+
if (transport?.type === 'fallback') {
|
|
49
|
+
throw new Error('Fallback transport not supported. Please use a single HTTP transport instead.');
|
|
50
|
+
// TODO: implement with a code like the following:
|
|
51
|
+
// Note: The following takes only the first url of the transports urls.
|
|
52
|
+
// const items = transport.transports as ReturnType<Transport>[];
|
|
53
|
+
// const providers = items.map((t, i) => {
|
|
54
|
+
// const url = t?.value?.url;
|
|
55
|
+
// if (typeof url !== 'string' || url.length === 0) {
|
|
56
|
+
// throw new Error(
|
|
57
|
+
// `Fallback transport missing URL at index ${i} (chainId=${chain?.id ?? 'unknown'} name=${chain?.name ?? 'unknown'})`,
|
|
58
|
+
// );
|
|
59
|
+
// }
|
|
60
|
+
// return new ethers.providers.JsonRpcProvider(url, networkish);
|
|
61
|
+
// });
|
|
62
|
+
// return new ethers.providers.FallbackProvider(providers);
|
|
63
|
+
}
|
|
64
|
+
// websocket transport
|
|
65
|
+
if (transport?.type === 'webSocket') {
|
|
66
|
+
throw new Error('WebSocket transport not supported');
|
|
67
|
+
// TODO: implement with a code like the following:
|
|
68
|
+
// const url = transport?.url as string | undefined;
|
|
69
|
+
// if (!url) {
|
|
70
|
+
// throw new Error(
|
|
71
|
+
// `Transport must have a URL (type=webSocket, chainId=${chain?.id ?? 'unknown'} name=${chain?.name ?? 'unknown'})`,
|
|
72
|
+
// );
|
|
73
|
+
// }
|
|
74
|
+
// return new ethers.providers.WebSocketProvider(url, networkish);
|
|
75
|
+
}
|
|
76
|
+
// TODO: this needs to be a lot better tested
|
|
77
|
+
// custom (EIP-1193) transport
|
|
78
|
+
if (transport?.type === 'custom') {
|
|
79
|
+
const value = transport?.value;
|
|
80
|
+
const provider = value?.provider ?? value ?? transport;
|
|
81
|
+
// Check if it's an EIP-1193 provider (e.g., MetaMask, WalletConnect)
|
|
82
|
+
if (provider && typeof provider.request === 'function') {
|
|
83
|
+
return new ethers_1.ethers.providers.Web3Provider(provider, networkish);
|
|
84
|
+
}
|
|
85
|
+
// If custom but no EIP-1193 provider found, try URL if present
|
|
86
|
+
throw new Error('Custom non-EIP-1193 provider transport not supported');
|
|
87
|
+
// TODO: implement with a code like the following:
|
|
88
|
+
// const url = value?.url ?? transport?.url;
|
|
89
|
+
// if (typeof url === 'string' && url.length > 0) {
|
|
90
|
+
// return new ethers.providers.JsonRpcProvider(url, networkish);
|
|
91
|
+
// }
|
|
92
|
+
// throw new Error(
|
|
93
|
+
// `Custom transport missing EIP-1193 provider or URL (chainId=${chain?.id ?? 'unknown'} name=${chain?.name ?? 'unknown'})`,
|
|
94
|
+
// );
|
|
95
|
+
}
|
|
96
|
+
// Default: assume HTTP-like with a URL
|
|
97
|
+
const url = transport?.url;
|
|
98
|
+
if (!url) {
|
|
99
|
+
throw new Error(`Transport must have a URL (type=${transport?.type ?? 'unknown'}, chainId=${chain?.id ?? 'unknown'}, name=${chain?.name ?? 'unknown'})`);
|
|
100
|
+
}
|
|
101
|
+
return new ethers_1.ethers.providers.JsonRpcProvider(url, networkish);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=ethers-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ethers-adapter.js","sourceRoot":"","sources":["../../../src/viem/ethers-adapter.ts"],"names":[],"mappings":";;AAwCA,oDAiFC;AAxHD,mCAAgC;AAIhC;;GAEG;AACH,SAAS,gBAAgB,CAAC,KAAY;IACpC,MAAM,UAAU,GAAe;QAC7B,OAAO,EAAE,KAAK,CAAC,EAAE;QACjB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC;IAEF,wCAAwC;IACxC,2IAA2I;IAC3I,sFAAsF;IACtF,IAAI,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;QAC1C,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC;IAC9D,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH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AA+D;QAE/D,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QACxE,kDAAkD;QAClD,4CAA4C;QAC5C,mDAAmD;QACnD,kEAAkE;QAClE,IAAI;QACJ,mBAAmB;QACnB,8HAA8H;QAC9H,KAAK;IACP,CAAC;IAED,uCAAuC;IACvC,MAAM,GAAG,GAAG,SAAS,EAAE,GAAyB,CAAC;IACjD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,mCAAmC,SAAS,EAAE,IAAI,IAAI,SAAS,aAAa,KAAK,EAAE,EAAE,IAAI,SAAS,UAAU,KAAK,EAAE,IAAI,IAAI,SAAS,GAAG,CACxI,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,eAAM,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./type-guards.js"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/viem/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type TacoSigner } from '../taco-signer.js';
|
|
2
|
+
import { type Address, type SignerAccount } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Viem Signer Adapter
|
|
5
|
+
*
|
|
6
|
+
* This adapter implements the minimal TacoSigner interface for internal library use.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ViemSignerAdapter implements TacoSigner {
|
|
9
|
+
protected viemAccount: SignerAccount;
|
|
10
|
+
constructor(viemAccount: SignerAccount);
|
|
11
|
+
getAddress(): Promise<Address>;
|
|
12
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViemSignerAdapter = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
/**
|
|
6
|
+
* Viem Signer Adapter
|
|
7
|
+
*
|
|
8
|
+
* This adapter implements the minimal TacoSigner interface for internal library use.
|
|
9
|
+
*/
|
|
10
|
+
class ViemSignerAdapter {
|
|
11
|
+
viemAccount;
|
|
12
|
+
constructor(viemAccount) {
|
|
13
|
+
this.viemAccount = viemAccount;
|
|
14
|
+
}
|
|
15
|
+
async getAddress() {
|
|
16
|
+
let address;
|
|
17
|
+
if ('address' in this.viemAccount) {
|
|
18
|
+
// viemAccount is a LocalAccount
|
|
19
|
+
address = this.viemAccount.address;
|
|
20
|
+
}
|
|
21
|
+
else if ('account' in this.viemAccount &&
|
|
22
|
+
this.viemAccount.account &&
|
|
23
|
+
'address' in this.viemAccount.account) {
|
|
24
|
+
// viemAccount is a WalletClient
|
|
25
|
+
address = this.viemAccount.account.address;
|
|
26
|
+
}
|
|
27
|
+
if (address) {
|
|
28
|
+
// Get the checksummed address to avoid getting
|
|
29
|
+
// "invalid EIP-55 address - 0x31663c14545df87044d2c5407ad0c2696b6d1402"
|
|
30
|
+
// that might be thrown at package siwe-parser while perform decryption
|
|
31
|
+
return ethers_1.ethers.utils.getAddress(address);
|
|
32
|
+
}
|
|
33
|
+
throw new Error('Unable to retrieve address from viem account. Expected a LocalAccount with "address" property or WalletClient with "account.address" property.');
|
|
34
|
+
}
|
|
35
|
+
async signMessage(message) {
|
|
36
|
+
if (!this.viemAccount.signMessage) {
|
|
37
|
+
throw new Error('Account does not support message signing. Expected a LocalAccount or a WalletClient with signing capability.');
|
|
38
|
+
}
|
|
39
|
+
if (typeof message === 'string') {
|
|
40
|
+
return await this.viemAccount.signMessage({
|
|
41
|
+
account: await this.getAddress(),
|
|
42
|
+
message,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return await this.viemAccount.signMessage({
|
|
47
|
+
account: await this.getAddress(),
|
|
48
|
+
message: { raw: message },
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ViemSignerAdapter = ViemSignerAdapter;
|
|
54
|
+
//# sourceMappingURL=signer-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer-adapter.js","sourceRoot":"","sources":["../../../src/viem/signer-adapter.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAMhC;;;;GAIG;AACH,MAAa,iBAAiB;IAClB,WAAW,CAAgB;IAErC,YAAY,WAA0B;QACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,OAA4B,CAAC;QACjC,IAAI,SAAS,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAClC,gCAAgC;YAChC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;QACrC,CAAC;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