@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain.js","sourceRoot":"","sources":["../../src/domain.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,iDAAiD;IACjD,MAAM,EAAE;QACN,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,KAAK;KACf;IACD,2DAA2D;IAC3D,OAAO,EAAE;QACP,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,KAAK;KACf;IACD,wCAAwC;IACxC,OAAO,EAAE;QACP,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,GAAG;KACb;CACO,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,+DAA+D;IAC/D,MAAM,EAAE,MAAM;IACd,yEAAyE;IACzE,OAAO,EAAE,OAAO;IAChB,sDAAsD;IACtD,OAAO,EAAE,SAAS;CACV,CAAC"}
|
package/dist/es/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './adapters.js';
|
|
2
|
+
export * from './contracts/index.js';
|
|
3
|
+
export * from './domain.js';
|
|
4
|
+
export * from './porter.js';
|
|
5
|
+
export * from './schemas.js';
|
|
6
|
+
export * from './taco-signer.js';
|
|
7
|
+
export type * from './types.js';
|
|
8
|
+
export * from './utils.js';
|
|
9
|
+
export * from './viem/index.js';
|
|
10
|
+
export * from './web3.js';
|
|
7
11
|
export { Ciphertext, EncryptedTreasureMap, HRAC, MessageKit, PublicKey, SecretKey, Signer, TreasureMap, VerifiedKeyFrag, initialize, } from '@nucypher/nucypher-core';
|
package/dist/es/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './adapters.js';
|
|
2
|
+
export * from './contracts/index.js';
|
|
3
|
+
export * from './domain.js';
|
|
4
|
+
export * from './porter.js';
|
|
5
|
+
export * from './schemas.js';
|
|
6
|
+
export * from './taco-signer.js';
|
|
7
|
+
export * from './utils.js';
|
|
8
|
+
export * from './viem/index.js';
|
|
9
|
+
export * from './web3.js';
|
|
7
10
|
// Re-exports
|
|
8
11
|
export { Ciphertext, EncryptedTreasureMap, HRAC, MessageKit, PublicKey, SecretKey, Signer, TreasureMap, VerifiedKeyFrag, initialize, } from '@nucypher/nucypher-core';
|
|
9
12
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAE1B,aAAa;AACb,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,IAAI,EACJ,UAAU,EACV,SAAS,EACT,SAAS,EACT,MAAM,EACN,WAAW,EACX,eAAe,EACf,UAAU,GACX,MAAM,yBAAyB,CAAC"}
|
package/dist/es/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/es/porter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CapsuleFrag, EncryptedThresholdDecryptionResponse, PublicKey, } from '@nucypher/nucypher-core';
|
|
2
2
|
import axios, { HttpStatusCode, } from 'axios';
|
|
3
3
|
import qs from 'qs';
|
|
4
|
-
import { fromBase64, fromHexString, toBase64, toHexString } from './utils';
|
|
4
|
+
import { fromBase64, fromHexString, toBase64, toHexString } from './utils.js';
|
|
5
5
|
const defaultPorterUri = {
|
|
6
6
|
mainnet: 'https://porter.nucypher.io',
|
|
7
7
|
tapir: 'https://porter-tapir.nucypher.io',
|
|
@@ -43,23 +43,6 @@ export const getPorterUrisFromSource = async (domain) => {
|
|
|
43
43
|
return [];
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
function decodeSignature(signerAddress, signatureB64) {
|
|
47
|
-
try {
|
|
48
|
-
const decodedData = JSON.parse(new TextDecoder().decode(fromBase64(signatureB64)));
|
|
49
|
-
return {
|
|
50
|
-
result: {
|
|
51
|
-
messageHash: decodedData.message_hash,
|
|
52
|
-
signature: decodedData.signature,
|
|
53
|
-
signerAddress,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
return {
|
|
59
|
-
error: `Failed to decode signature: ${error}`,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
46
|
export class PorterClient {
|
|
64
47
|
porterUrls;
|
|
65
48
|
constructor(porterUris) {
|
|
@@ -82,17 +65,6 @@ export class PorterClient {
|
|
|
82
65
|
}
|
|
83
66
|
}
|
|
84
67
|
catch (e) {
|
|
85
|
-
const errorDetails = {
|
|
86
|
-
url: porterUrl.toString(),
|
|
87
|
-
method: config.method,
|
|
88
|
-
requestData: config.data,
|
|
89
|
-
};
|
|
90
|
-
if (axios.isAxiosError(e)) {
|
|
91
|
-
errorDetails.status = e.response?.status;
|
|
92
|
-
errorDetails.statusText = e.response?.statusText;
|
|
93
|
-
errorDetails.data = e.response?.data;
|
|
94
|
-
}
|
|
95
|
-
console.error('Porter request failed:', errorDetails);
|
|
96
68
|
lastError = e;
|
|
97
69
|
continue;
|
|
98
70
|
}
|
|
@@ -166,33 +138,5 @@ export class PorterClient {
|
|
|
166
138
|
const encryptedResponses = Object.fromEntries(decryptionResponses);
|
|
167
139
|
return { encryptedResponses, errors };
|
|
168
140
|
}
|
|
169
|
-
async signUserOp(signingRequests, threshold) {
|
|
170
|
-
const data = {
|
|
171
|
-
signing_requests: signingRequests,
|
|
172
|
-
threshold: threshold,
|
|
173
|
-
};
|
|
174
|
-
const resp = await this.tryAndCall({
|
|
175
|
-
url: '/sign',
|
|
176
|
-
method: 'post',
|
|
177
|
-
data,
|
|
178
|
-
});
|
|
179
|
-
const { signatures, errors } = resp.data.result.signing_results;
|
|
180
|
-
const allErrors = { ...errors };
|
|
181
|
-
const signingResults = {};
|
|
182
|
-
for (const [ursulaAddress, [signerAddress, signatureB64]] of Object.entries(signatures || {})) {
|
|
183
|
-
const decoded = decodeSignature(signerAddress, signatureB64);
|
|
184
|
-
if (decoded.error) {
|
|
185
|
-
// issue with decoding signature, add to errors
|
|
186
|
-
allErrors[ursulaAddress] = decoded.error;
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
// Always include all decoded signatures in signingResults
|
|
190
|
-
signingResults[ursulaAddress] = decoded.result;
|
|
191
|
-
}
|
|
192
|
-
return {
|
|
193
|
-
signingResults,
|
|
194
|
-
errors: allErrors,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
141
|
}
|
|
198
142
|
//# sourceMappingURL=porter.js.map
|
package/dist/es/porter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"porter.js","sourceRoot":"","sources":["../../src/porter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,oCAAoC,EACpC,SAAS,GAGV,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,EAGZ,cAAc,GACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"porter.js","sourceRoot":"","sources":["../../src/porter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,oCAAoC,EACpC,SAAS,GAGV,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,EAGZ,cAAc,GACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,MAAM,IAAI,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;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;AAK1F,MAAM,CAAC,MAAM,OAAO,GAA2B;IAC7C,MAAM,EAAE,MAAM;I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B,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,uBAAuB,CAAC,EAAE,EAAE;YAC3C,MAAM,iBAAiB,GAAG,oCAAoC,CAAC,SAAS,CACtE,UAAU,CAAC,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"}
|
package/dist/es/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/es/schemas.js
CHANGED
|
@@ -8,22 +8,9 @@ const isAddress = (address) => {
|
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
const isAddressStrict = (address) => {
|
|
12
|
-
try {
|
|
13
|
-
// Verify the address was checksummed to prevent passing an address that has a typo
|
|
14
|
-
return address === ethers.utils.getAddress(address);
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
// If any error occurs during validation, fail the validation
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
11
|
export const EthAddressSchema = z
|
|
22
12
|
.string()
|
|
23
13
|
.refine(isAddress, { message: 'Invalid Ethereum address' });
|
|
24
|
-
export const EthAddressSchemaStrict = z.string().refine(isAddressStrict, {
|
|
25
|
-
message: 'Invalid Ethereum address - it must be valid and checksummed',
|
|
26
|
-
});
|
|
27
14
|
const BLOCK_HASH_REGEXP = new RegExp('^0x[a-fA-F0-9]{64}$');
|
|
28
15
|
const BlockNumber = z.number().int().nonnegative();
|
|
29
16
|
const BlockHash = z.string().regex(BLOCK_HASH_REGEXP, 'Invalid block hash');
|
package/dist/es/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,SAAS,GAAG,CAAC,OAAe,EAAE,EAAE;IACpC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,EAAE;KACR,MAAM,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC,CAAC;AAE9D,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAC5D,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;AACnD,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;AAC5E,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC3C,WAAW;IACX,SAAS;IACT,QAAQ;CACT,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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/es/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/es/types.js
CHANGED
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export class UserOperationSignatureRequest {
|
|
3
|
-
userOp;
|
|
4
|
-
aaVersion;
|
|
5
|
-
cohortId;
|
|
6
|
-
chainId;
|
|
7
|
-
context;
|
|
8
|
-
signatureType;
|
|
9
|
-
constructor(userOp, aaVersion, cohortId, chainId, context = {}, signatureType = 'userop') {
|
|
10
|
-
this.userOp = userOp;
|
|
11
|
-
this.aaVersion = aaVersion;
|
|
12
|
-
this.cohortId = cohortId;
|
|
13
|
-
this.chainId = chainId;
|
|
14
|
-
this.context = context;
|
|
15
|
-
this.signatureType = signatureType;
|
|
16
|
-
}
|
|
17
|
-
toBytes() {
|
|
18
|
-
const data = {
|
|
19
|
-
user_op: JSON.stringify(this.userOp),
|
|
20
|
-
aa_version: this.aaVersion,
|
|
21
|
-
cohort_id: this.cohortId,
|
|
22
|
-
chain_id: this.chainId,
|
|
23
|
-
context: this.context,
|
|
24
|
-
signature_type: this.signatureType,
|
|
25
|
-
};
|
|
26
|
-
return new TextEncoder().encode(JSON.stringify(data));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function normalizeAddress(address) {
|
|
30
|
-
if (!address || address === '0x') {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
// Use ethers to get the checksummed address - this will throw on invalid addresses
|
|
35
|
-
return ethers.utils.getAddress(address);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
// Re-throw the error to fail fast on invalid addresses
|
|
39
|
-
throw new Error(`Invalid address: ${address}. ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export function convertUserOperationToPython(userOp) {
|
|
43
|
-
return {
|
|
44
|
-
sender: normalizeAddress(userOp.sender),
|
|
45
|
-
nonce: userOp.nonce,
|
|
46
|
-
factory: normalizeAddress(userOp.factory),
|
|
47
|
-
factory_data: userOp.factoryData || '0x',
|
|
48
|
-
call_data: userOp.callData || '0x',
|
|
49
|
-
call_gas_limit: userOp.callGasLimit,
|
|
50
|
-
verification_gas_limit: userOp.verificationGasLimit,
|
|
51
|
-
pre_verification_gas: userOp.preVerificationGas,
|
|
52
|
-
max_fee_per_gas: userOp.maxFeePerGas,
|
|
53
|
-
max_priority_fee_per_gas: userOp.maxPriorityFeePerGas,
|
|
54
|
-
paymaster: normalizeAddress(userOp.paymaster),
|
|
55
|
-
paymaster_verification_gas_limit: userOp.paymasterVerificationGasLimit,
|
|
56
|
-
paymaster_post_op_gas_limit: userOp.paymasterPostOpGasLimit,
|
|
57
|
-
paymaster_data: userOp.paymasterData || '0x',
|
|
58
|
-
signature: userOp.signature || '0x',
|
|
59
|
-
};
|
|
60
|
-
}
|
|
1
|
+
export {};
|
|
61
2
|
//# sourceMappingURL=types.js.map
|
package/dist/es/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,100 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Create ethers network object from viem chain
|
|
4
|
+
*/
|
|
5
|
+
function createNetworkish(chain) {
|
|
6
|
+
const networkish = {
|
|
7
|
+
chainId: chain.id,
|
|
8
|
+
name: chain.name,
|
|
9
|
+
};
|
|
10
|
+
// Add ENS registry address if available
|
|
11
|
+
// 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).
|
|
12
|
+
// Therefore, no need to take any action if the ENS registry address is not available.
|
|
13
|
+
if (chain.contracts?.ensRegistry?.address) {
|
|
14
|
+
networkish.ensAddress = chain.contracts.ensRegistry.address;
|
|
15
|
+
}
|
|
16
|
+
return networkish;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Viem to Ethers.js Adapter for Providers
|
|
20
|
+
*
|
|
21
|
+
* This adapter converts viem PublicClients to actual ethers.js Provider instances.
|
|
22
|
+
* Unlike the signer adapter which implements a minimal internal interface,
|
|
23
|
+
* this creates real ethers.providers.Provider objects that can be passed to
|
|
24
|
+
* third-party libraries expecting ethers.js providers.
|
|
25
|
+
*
|
|
26
|
+
* Key differences from signer adapter:
|
|
27
|
+
* - Creates ethers.providers.Provider instances
|
|
28
|
+
* - Currently handles only transport type: http
|
|
29
|
+
* - Required for external library compatibility
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Static method to directly convert client to provider (convenience method)
|
|
33
|
+
*/
|
|
34
|
+
export function viemClientToProvider(client) {
|
|
35
|
+
const { chain, transport } = client;
|
|
36
|
+
let networkish;
|
|
37
|
+
if (chain) {
|
|
38
|
+
networkish = createNetworkish(chain);
|
|
39
|
+
}
|
|
40
|
+
// Note: We read minimal, commonly-present properties from transport.
|
|
41
|
+
// viem's transport internals are not a public API and may change.
|
|
42
|
+
// Also the we are taking only the first transport available.
|
|
43
|
+
// This adapter focuses on best-effort extraction of an RPC URL or EIP-1193 provider.
|
|
44
|
+
// fallback transport (multiple RPC endpoints)
|
|
45
|
+
if (transport?.type === 'fallback') {
|
|
46
|
+
throw new Error('Fallback transport not supported. Please use a single HTTP transport instead.');
|
|
47
|
+
// TODO: implement with a code like the following:
|
|
48
|
+
// Note: The following takes only the first url of the transports urls.
|
|
49
|
+
// const items = transport.transports as ReturnType<Transport>[];
|
|
50
|
+
// const providers = items.map((t, i) => {
|
|
51
|
+
// const url = t?.value?.url;
|
|
52
|
+
// if (typeof url !== 'string' || url.length === 0) {
|
|
53
|
+
// throw new Error(
|
|
54
|
+
// `Fallback transport missing URL at index ${i} (chainId=${chain?.id ?? 'unknown'} name=${chain?.name ?? 'unknown'})`,
|
|
55
|
+
// );
|
|
56
|
+
// }
|
|
57
|
+
// return new ethers.providers.JsonRpcProvider(url, networkish);
|
|
58
|
+
// });
|
|
59
|
+
// return new ethers.providers.FallbackProvider(providers);
|
|
60
|
+
}
|
|
61
|
+
// websocket transport
|
|
62
|
+
if (transport?.type === 'webSocket') {
|
|
63
|
+
throw new Error('WebSocket transport not supported');
|
|
64
|
+
// TODO: implement with a code like the following:
|
|
65
|
+
// const url = transport?.url as string | undefined;
|
|
66
|
+
// if (!url) {
|
|
67
|
+
// throw new Error(
|
|
68
|
+
// `Transport must have a URL (type=webSocket, chainId=${chain?.id ?? 'unknown'} name=${chain?.name ?? 'unknown'})`,
|
|
69
|
+
// );
|
|
70
|
+
// }
|
|
71
|
+
// return new ethers.providers.WebSocketProvider(url, networkish);
|
|
72
|
+
}
|
|
73
|
+
// TODO: this needs to be a lot better tested
|
|
74
|
+
// custom (EIP-1193) transport
|
|
75
|
+
if (transport?.type === 'custom') {
|
|
76
|
+
const value = transport?.value;
|
|
77
|
+
const provider = value?.provider ?? value ?? transport;
|
|
78
|
+
// Check if it's an EIP-1193 provider (e.g., MetaMask, WalletConnect)
|
|
79
|
+
if (provider && typeof provider.request === 'function') {
|
|
80
|
+
return new ethers.providers.Web3Provider(provider, networkish);
|
|
81
|
+
}
|
|
82
|
+
// If custom but no EIP-1193 provider found, try URL if present
|
|
83
|
+
throw new Error('Custom non-EIP-1193 provider transport not supported');
|
|
84
|
+
// TODO: implement with a code like the following:
|
|
85
|
+
// const url = value?.url ?? transport?.url;
|
|
86
|
+
// if (typeof url === 'string' && url.length > 0) {
|
|
87
|
+
// return new ethers.providers.JsonRpcProvider(url, networkish);
|
|
88
|
+
// }
|
|
89
|
+
// throw new Error(
|
|
90
|
+
// `Custom transport missing EIP-1193 provider or URL (chainId=${chain?.id ?? 'unknown'} name=${chain?.name ?? 'unknown'})`,
|
|
91
|
+
// );
|
|
92
|
+
}
|
|
93
|
+
// Default: assume HTTP-like with a URL
|
|
94
|
+
const url = transport?.url;
|
|
95
|
+
if (!url) {
|
|
96
|
+
throw new Error(`Transport must have a URL (type=${transport?.type ?? 'unknown'}, chainId=${chain?.id ?? 'unknown'}, name=${chain?.name ?? 'unknown'})`);
|
|
97
|
+
}
|
|
98
|
+
return new ethers.providers.JsonRpcProvider(url, networkish);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=ethers-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ethers-adapter.js","sourceRoot":"","sources":["../../../src/viem/ethers-adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;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,C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AAU,EAAE,CAAC;YACvD,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACjE,CAAC;QAED,+DAA+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,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/viem/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -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,50 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Viem Signer Adapter
|
|
4
|
+
*
|
|
5
|
+
* This adapter implements the minimal TacoSigner interface for internal library use.
|
|
6
|
+
*/
|
|
7
|
+
export class ViemSignerAdapter {
|
|
8
|
+
viemAccount;
|
|
9
|
+
constructor(viemAccount) {
|
|
10
|
+
this.viemAccount = viemAccount;
|
|
11
|
+
}
|
|
12
|
+
async getAddress() {
|
|
13
|
+
let address;
|
|
14
|
+
if ('address' in this.viemAccount) {
|
|
15
|
+
// viemAccount is a LocalAccount
|
|
16
|
+
address = this.viemAccount.address;
|
|
17
|
+
}
|
|
18
|
+
else if ('account' in this.viemAccount &&
|
|
19
|
+
this.viemAccount.account &&
|
|
20
|
+
'address' in this.viemAccount.account) {
|
|
21
|
+
// viemAccount is a WalletClient
|
|
22
|
+
address = this.viemAccount.account.address;
|
|
23
|
+
}
|
|
24
|
+
if (address) {
|
|
25
|
+
// Get the checksummed address to avoid getting
|
|
26
|
+
// "invalid EIP-55 address - 0x31663c14545df87044d2c5407ad0c2696b6d1402"
|
|
27
|
+
// that might be thrown at package siwe-parser while perform decryption
|
|
28
|
+
return ethers.utils.getAddress(address);
|
|
29
|
+
}
|
|
30
|
+
throw new Error('Unable to retrieve address from viem account. Expected a LocalAccount with "address" property or WalletClient with "account.address" property.');
|
|
31
|
+
}
|
|
32
|
+
async signMessage(message) {
|
|
33
|
+
if (!this.viemAccount.signMessage) {
|
|
34
|
+
throw new Error('Account does not support message signing. Expected a LocalAccount or a WalletClient with signing capability.');
|
|
35
|
+
}
|
|
36
|
+
if (typeof message === 'string') {
|
|
37
|
+
return await this.viemAccount.signMessage({
|
|
38
|
+
account: await this.getAddress(),
|
|
39
|
+
message,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return await this.viemAccount.signMessage({
|
|
44
|
+
account: await this.getAddress(),
|
|
45
|
+
message: { raw: message },
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# 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,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC;;;;GAIG;AACH,MAAM,OAAO,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;aAAM,IACL,SAAS,IAAI,IAAI,CAAC,WAAW;YAC7B,IAAI,CAAC,WAAW,CAAC,OAAO;YACxB,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EACrC,CAAC;YACD,gCAAgC;YAChC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7C,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,+CAA+C;YAC/C,wEAAwE;YACxE,uEAAuE;YACvE,OAAO,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAY,CAAC;QACrD,CAAC;QACD,MAAM,IAAI,KAAK,CACb,gJAAgJ,CACjJ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAA4B;QAC5C,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,8GAA8G,CAC/G,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;gBACxC,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE;gBAChC,OAAO;aACR,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;gBACxC,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE;gBAChC,OAAO,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;aAC1B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProviderLike, SignerLike } from '../types.js';
|
|
2
|
+
import { PublicClient, SignerAccount } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Type guard to determine if the provider-like is a viem PublicClient
|
|
5
|
+
*
|
|
6
|
+
* Checks for:
|
|
7
|
+
* - Ensures it's not an ethers provider instance
|
|
8
|
+
* - Presence of viem-specific properties (chain)
|
|
9
|
+
* - Presence of viem-specific methods (getChainId)
|
|
10
|
+
*/
|
|
11
|
+
export declare function isViemClient(providerLike: ProviderLike): providerLike is PublicClient;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to determine if the signer is a viem account that can sign: LocalAccount or WalletClient
|
|
14
|
+
* Note: might need modification when supporting viem SmartAccount
|
|
15
|
+
* Checks for:
|
|
16
|
+
* - Ensures it's not an ethers Signer instance
|
|
17
|
+
* - Absence of ethers-specific properties (provider)
|
|
18
|
+
* - Presence of viem Local Account properties (address as string) or viem Wallet Client properties (account.address as string)
|
|
19
|
+
*/
|
|
20
|
+
export declare function isViemSignerAccount(signer: SignerLike): signer is SignerAccount;
|