@appliedblockchain/silentdatarollup-core 1.0.6 → 1.0.8
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/README.md +1 -1
- package/dist/{chunk-PTTWND7Y.mjs → chunk-5JD3GAHS.mjs} +5 -39
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -34
- package/dist/index.mjs +3 -1
- package/dist/tests.d.mts +1 -1
- package/dist/tests.d.ts +1 -1
- package/dist/tests.js +2 -0
- package/dist/tests.mjs +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,6 @@ var SIGN_RPC_METHODS = [
|
|
|
6
6
|
"eth_estimateGas",
|
|
7
7
|
"eth_getProof",
|
|
8
8
|
"eth_getTransactionByHash",
|
|
9
|
-
"eth_getTransactionCount",
|
|
10
9
|
"eth_getTransactionReceipt"
|
|
11
10
|
];
|
|
12
11
|
var eip721Domain = {
|
|
@@ -27,6 +26,7 @@ var HEADER_EIP712_SIGNATURE = "x-eip712-signature";
|
|
|
27
26
|
var HEADER_DELEGATE = "x-delegate";
|
|
28
27
|
var HEADER_DELEGATE_SIGNATURE = "x-delegate-signature";
|
|
29
28
|
var HEADER_EIP712_DELEGATE_SIGNATURE = "x-eip712-delegate-signature";
|
|
29
|
+
var HEADER_SIGNER_SWC = "x-signer-swc";
|
|
30
30
|
var DEFAULT_DELEGATE_EXPIRES = 10 * 60 * 60;
|
|
31
31
|
var DELEGATE_EXPIRATION_THRESHOLD_BUFFER = 5;
|
|
32
32
|
var WHITELISTED_METHODS = [
|
|
@@ -535,44 +535,10 @@ var SilentDataRollupBase = class {
|
|
|
535
535
|
};
|
|
536
536
|
|
|
537
537
|
// src/contract.ts
|
|
538
|
-
import {
|
|
539
|
-
Contract,
|
|
540
|
-
Interface,
|
|
541
|
-
assertArgument
|
|
542
|
-
} from "ethers";
|
|
543
|
-
var CustomContractRunner = class {
|
|
544
|
-
constructor(provider, signer) {
|
|
545
|
-
this.provider = provider;
|
|
546
|
-
this.signer = signer;
|
|
547
|
-
}
|
|
548
|
-
async sendTransaction(tx) {
|
|
549
|
-
const signerAddress = await this.signer.getAddress();
|
|
550
|
-
const latestNonce = await this.provider.getTransactionCount(
|
|
551
|
-
signerAddress,
|
|
552
|
-
"latest"
|
|
553
|
-
);
|
|
554
|
-
tx.nonce = latestNonce;
|
|
555
|
-
if (!tx.gasLimit) {
|
|
556
|
-
tx.gasLimit = await this.provider.estimateGas(tx);
|
|
557
|
-
}
|
|
558
|
-
return this.signer.sendTransaction(tx);
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
function getContractRunner(runner, provider) {
|
|
562
|
-
const runnerIsSigner = typeof runner.sendTransaction === "function";
|
|
563
|
-
if (!runnerIsSigner) {
|
|
564
|
-
return runner;
|
|
565
|
-
}
|
|
566
|
-
const runnerProviderConstructor = runner.provider?.constructor.name ?? "";
|
|
567
|
-
if (!runnerProviderConstructor.includes("SilentDataRollupProvider")) {
|
|
568
|
-
assertArgument(provider, "provider is mandatory", "provider", provider);
|
|
569
|
-
return new CustomContractRunner(provider, runner);
|
|
570
|
-
}
|
|
571
|
-
return new CustomContractRunner(runner.provider, runner);
|
|
572
|
-
}
|
|
538
|
+
import { Contract, Interface } from "ethers";
|
|
573
539
|
var SilentDataRollupContract = class extends Contract {
|
|
574
540
|
constructor(config) {
|
|
575
|
-
const { address, abi, runner, contractMethodsToSign
|
|
541
|
+
const { address, abi, runner, contractMethodsToSign } = config;
|
|
576
542
|
const contractInterface = new Interface(abi);
|
|
577
543
|
contractMethodsToSign.forEach((method) => {
|
|
578
544
|
if (!contractInterface.hasFunction(method)) {
|
|
@@ -581,8 +547,7 @@ var SilentDataRollupContract = class extends Contract {
|
|
|
581
547
|
);
|
|
582
548
|
}
|
|
583
549
|
});
|
|
584
|
-
|
|
585
|
-
super(address, abi, contractRunner);
|
|
550
|
+
super(address, abi, runner);
|
|
586
551
|
const baseProvider = runner.baseProvider || runner.provider?.baseProvider;
|
|
587
552
|
if (typeof baseProvider?.setContract === "function") {
|
|
588
553
|
baseProvider.setContract(this, contractMethodsToSign);
|
|
@@ -612,6 +577,7 @@ export {
|
|
|
612
577
|
HEADER_DELEGATE,
|
|
613
578
|
HEADER_DELEGATE_SIGNATURE,
|
|
614
579
|
HEADER_EIP712_DELEGATE_SIGNATURE,
|
|
580
|
+
HEADER_SIGNER_SWC,
|
|
615
581
|
DEFAULT_DELEGATE_EXPIRES,
|
|
616
582
|
DELEGATE_EXPIRATION_THRESHOLD_BUFFER,
|
|
617
583
|
WHITELISTED_METHODS,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer, Contract, JsonRpcPayload, InterfaceAbi, ContractRunner,
|
|
1
|
+
import { Signer, Contract, JsonRpcPayload, InterfaceAbi, ContractRunner, TypedDataDomain, TypedDataField } from 'ethers';
|
|
2
2
|
|
|
3
3
|
declare const SIGN_RPC_METHODS: string[];
|
|
4
4
|
declare const eip721Domain: {
|
|
@@ -19,6 +19,7 @@ declare const HEADER_EIP712_SIGNATURE = "x-eip712-signature";
|
|
|
19
19
|
declare const HEADER_DELEGATE = "x-delegate";
|
|
20
20
|
declare const HEADER_DELEGATE_SIGNATURE = "x-delegate-signature";
|
|
21
21
|
declare const HEADER_EIP712_DELEGATE_SIGNATURE = "x-eip712-delegate-signature";
|
|
22
|
+
declare const HEADER_SIGNER_SWC = "x-signer-swc";
|
|
22
23
|
declare const DEFAULT_DELEGATE_EXPIRES: number;
|
|
23
24
|
/**
|
|
24
25
|
* A buffer time (in seconds) added to the current time when verifying the validity of a delegate.
|
|
@@ -99,7 +100,6 @@ type SilentDataRollupContractConfig = {
|
|
|
99
100
|
abi: InterfaceAbi;
|
|
100
101
|
runner: ContractRunner;
|
|
101
102
|
contractMethodsToSign: string[];
|
|
102
|
-
provider?: Provider;
|
|
103
103
|
};
|
|
104
104
|
type ContractInfo = {
|
|
105
105
|
contract: Contract;
|
|
@@ -241,4 +241,4 @@ interface PrivateEvent {
|
|
|
241
241
|
*/
|
|
242
242
|
declare function calculateEventTypeHash(eventSignature: string): string;
|
|
243
243
|
|
|
244
|
-
export { type AuthHeaders, type AuthSignatureMessage, type AuthSignatureMessageRequest, type BaseConfig, ChainId, type ContractInfo, DEBUG_NAMESPACE, DEBUG_NAMESPACE_SILENTDATA_INTERCEPTOR, DEFAULT_DELEGATE_EXPIRES, DELEGATE_EXPIRATION_THRESHOLD_BUFFER, type DelegateConfig, type DelegateHeaders, type DelegateSignerMessage, HEADER_DELEGATE, HEADER_DELEGATE_SIGNATURE, HEADER_EIP712_DELEGATE_SIGNATURE, HEADER_EIP712_SIGNATURE, HEADER_SIGNATURE, HEADER_TIMESTAMP, NetworkName, PRIVATE_EVENT_SIGNATURE, PRIVATE_EVENT_SIGNATURE_HASH, type PrivateEvent, SIGN_RPC_METHODS, SignatureType, type SilentDataProviderOptions, SilentDataRollupBase, SilentDataRollupContract, type SilentDataRollupContractConfig, type SilentdataNetworkConfig, WHITELISTED_METHODS, calculateEventTypeHash, defaultGetDelegate, delegateEIP721Types, eip721Domain, getAuthEIP721Types, getAuthHeaders, isSignableContractCall, prepareTypedDataPayload };
|
|
244
|
+
export { type AuthHeaders, type AuthSignatureMessage, type AuthSignatureMessageRequest, type BaseConfig, ChainId, type ContractInfo, DEBUG_NAMESPACE, DEBUG_NAMESPACE_SILENTDATA_INTERCEPTOR, DEFAULT_DELEGATE_EXPIRES, DELEGATE_EXPIRATION_THRESHOLD_BUFFER, type DelegateConfig, type DelegateHeaders, type DelegateSignerMessage, HEADER_DELEGATE, HEADER_DELEGATE_SIGNATURE, HEADER_EIP712_DELEGATE_SIGNATURE, HEADER_EIP712_SIGNATURE, HEADER_SIGNATURE, HEADER_SIGNER_SWC, HEADER_TIMESTAMP, NetworkName, PRIVATE_EVENT_SIGNATURE, PRIVATE_EVENT_SIGNATURE_HASH, type PrivateEvent, SIGN_RPC_METHODS, SignatureType, type SilentDataProviderOptions, SilentDataRollupBase, SilentDataRollupContract, type SilentDataRollupContractConfig, type SilentdataNetworkConfig, WHITELISTED_METHODS, calculateEventTypeHash, defaultGetDelegate, delegateEIP721Types, eip721Domain, getAuthEIP721Types, getAuthHeaders, isSignableContractCall, prepareTypedDataPayload };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer, Contract, JsonRpcPayload, InterfaceAbi, ContractRunner,
|
|
1
|
+
import { Signer, Contract, JsonRpcPayload, InterfaceAbi, ContractRunner, TypedDataDomain, TypedDataField } from 'ethers';
|
|
2
2
|
|
|
3
3
|
declare const SIGN_RPC_METHODS: string[];
|
|
4
4
|
declare const eip721Domain: {
|
|
@@ -19,6 +19,7 @@ declare const HEADER_EIP712_SIGNATURE = "x-eip712-signature";
|
|
|
19
19
|
declare const HEADER_DELEGATE = "x-delegate";
|
|
20
20
|
declare const HEADER_DELEGATE_SIGNATURE = "x-delegate-signature";
|
|
21
21
|
declare const HEADER_EIP712_DELEGATE_SIGNATURE = "x-eip712-delegate-signature";
|
|
22
|
+
declare const HEADER_SIGNER_SWC = "x-signer-swc";
|
|
22
23
|
declare const DEFAULT_DELEGATE_EXPIRES: number;
|
|
23
24
|
/**
|
|
24
25
|
* A buffer time (in seconds) added to the current time when verifying the validity of a delegate.
|
|
@@ -99,7 +100,6 @@ type SilentDataRollupContractConfig = {
|
|
|
99
100
|
abi: InterfaceAbi;
|
|
100
101
|
runner: ContractRunner;
|
|
101
102
|
contractMethodsToSign: string[];
|
|
102
|
-
provider?: Provider;
|
|
103
103
|
};
|
|
104
104
|
type ContractInfo = {
|
|
105
105
|
contract: Contract;
|
|
@@ -241,4 +241,4 @@ interface PrivateEvent {
|
|
|
241
241
|
*/
|
|
242
242
|
declare function calculateEventTypeHash(eventSignature: string): string;
|
|
243
243
|
|
|
244
|
-
export { type AuthHeaders, type AuthSignatureMessage, type AuthSignatureMessageRequest, type BaseConfig, ChainId, type ContractInfo, DEBUG_NAMESPACE, DEBUG_NAMESPACE_SILENTDATA_INTERCEPTOR, DEFAULT_DELEGATE_EXPIRES, DELEGATE_EXPIRATION_THRESHOLD_BUFFER, type DelegateConfig, type DelegateHeaders, type DelegateSignerMessage, HEADER_DELEGATE, HEADER_DELEGATE_SIGNATURE, HEADER_EIP712_DELEGATE_SIGNATURE, HEADER_EIP712_SIGNATURE, HEADER_SIGNATURE, HEADER_TIMESTAMP, NetworkName, PRIVATE_EVENT_SIGNATURE, PRIVATE_EVENT_SIGNATURE_HASH, type PrivateEvent, SIGN_RPC_METHODS, SignatureType, type SilentDataProviderOptions, SilentDataRollupBase, SilentDataRollupContract, type SilentDataRollupContractConfig, type SilentdataNetworkConfig, WHITELISTED_METHODS, calculateEventTypeHash, defaultGetDelegate, delegateEIP721Types, eip721Domain, getAuthEIP721Types, getAuthHeaders, isSignableContractCall, prepareTypedDataPayload };
|
|
244
|
+
export { type AuthHeaders, type AuthSignatureMessage, type AuthSignatureMessageRequest, type BaseConfig, ChainId, type ContractInfo, DEBUG_NAMESPACE, DEBUG_NAMESPACE_SILENTDATA_INTERCEPTOR, DEFAULT_DELEGATE_EXPIRES, DELEGATE_EXPIRATION_THRESHOLD_BUFFER, type DelegateConfig, type DelegateHeaders, type DelegateSignerMessage, HEADER_DELEGATE, HEADER_DELEGATE_SIGNATURE, HEADER_EIP712_DELEGATE_SIGNATURE, HEADER_EIP712_SIGNATURE, HEADER_SIGNATURE, HEADER_SIGNER_SWC, HEADER_TIMESTAMP, NetworkName, PRIVATE_EVENT_SIGNATURE, PRIVATE_EVENT_SIGNATURE_HASH, type PrivateEvent, SIGN_RPC_METHODS, SignatureType, type SilentDataProviderOptions, SilentDataRollupBase, SilentDataRollupContract, type SilentDataRollupContractConfig, type SilentdataNetworkConfig, WHITELISTED_METHODS, calculateEventTypeHash, defaultGetDelegate, delegateEIP721Types, eip721Domain, getAuthEIP721Types, getAuthHeaders, isSignableContractCall, prepareTypedDataPayload };
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
HEADER_EIP712_DELEGATE_SIGNATURE: () => HEADER_EIP712_DELEGATE_SIGNATURE,
|
|
41
41
|
HEADER_EIP712_SIGNATURE: () => HEADER_EIP712_SIGNATURE,
|
|
42
42
|
HEADER_SIGNATURE: () => HEADER_SIGNATURE,
|
|
43
|
+
HEADER_SIGNER_SWC: () => HEADER_SIGNER_SWC,
|
|
43
44
|
HEADER_TIMESTAMP: () => HEADER_TIMESTAMP,
|
|
44
45
|
NetworkName: () => NetworkName,
|
|
45
46
|
PRIVATE_EVENT_SIGNATURE: () => PRIVATE_EVENT_SIGNATURE,
|
|
@@ -68,7 +69,6 @@ var SIGN_RPC_METHODS = [
|
|
|
68
69
|
"eth_estimateGas",
|
|
69
70
|
"eth_getProof",
|
|
70
71
|
"eth_getTransactionByHash",
|
|
71
|
-
"eth_getTransactionCount",
|
|
72
72
|
"eth_getTransactionReceipt"
|
|
73
73
|
];
|
|
74
74
|
var eip721Domain = {
|
|
@@ -89,6 +89,7 @@ var HEADER_EIP712_SIGNATURE = "x-eip712-signature";
|
|
|
89
89
|
var HEADER_DELEGATE = "x-delegate";
|
|
90
90
|
var HEADER_DELEGATE_SIGNATURE = "x-delegate-signature";
|
|
91
91
|
var HEADER_EIP712_DELEGATE_SIGNATURE = "x-eip712-delegate-signature";
|
|
92
|
+
var HEADER_SIGNER_SWC = "x-signer-swc";
|
|
92
93
|
var DEFAULT_DELEGATE_EXPIRES = 10 * 60 * 60;
|
|
93
94
|
var DELEGATE_EXPIRATION_THRESHOLD_BUFFER = 5;
|
|
94
95
|
var WHITELISTED_METHODS = [
|
|
@@ -598,39 +599,9 @@ var SilentDataRollupBase = class {
|
|
|
598
599
|
|
|
599
600
|
// src/contract.ts
|
|
600
601
|
var import_ethers2 = require("ethers");
|
|
601
|
-
var CustomContractRunner = class {
|
|
602
|
-
constructor(provider, signer) {
|
|
603
|
-
this.provider = provider;
|
|
604
|
-
this.signer = signer;
|
|
605
|
-
}
|
|
606
|
-
async sendTransaction(tx) {
|
|
607
|
-
const signerAddress = await this.signer.getAddress();
|
|
608
|
-
const latestNonce = await this.provider.getTransactionCount(
|
|
609
|
-
signerAddress,
|
|
610
|
-
"latest"
|
|
611
|
-
);
|
|
612
|
-
tx.nonce = latestNonce;
|
|
613
|
-
if (!tx.gasLimit) {
|
|
614
|
-
tx.gasLimit = await this.provider.estimateGas(tx);
|
|
615
|
-
}
|
|
616
|
-
return this.signer.sendTransaction(tx);
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
function getContractRunner(runner, provider) {
|
|
620
|
-
const runnerIsSigner = typeof runner.sendTransaction === "function";
|
|
621
|
-
if (!runnerIsSigner) {
|
|
622
|
-
return runner;
|
|
623
|
-
}
|
|
624
|
-
const runnerProviderConstructor = runner.provider?.constructor.name ?? "";
|
|
625
|
-
if (!runnerProviderConstructor.includes("SilentDataRollupProvider")) {
|
|
626
|
-
(0, import_ethers2.assertArgument)(provider, "provider is mandatory", "provider", provider);
|
|
627
|
-
return new CustomContractRunner(provider, runner);
|
|
628
|
-
}
|
|
629
|
-
return new CustomContractRunner(runner.provider, runner);
|
|
630
|
-
}
|
|
631
602
|
var SilentDataRollupContract = class extends import_ethers2.Contract {
|
|
632
603
|
constructor(config) {
|
|
633
|
-
const { address, abi, runner, contractMethodsToSign
|
|
604
|
+
const { address, abi, runner, contractMethodsToSign } = config;
|
|
634
605
|
const contractInterface = new import_ethers2.Interface(abi);
|
|
635
606
|
contractMethodsToSign.forEach((method) => {
|
|
636
607
|
if (!contractInterface.hasFunction(method)) {
|
|
@@ -639,8 +610,7 @@ var SilentDataRollupContract = class extends import_ethers2.Contract {
|
|
|
639
610
|
);
|
|
640
611
|
}
|
|
641
612
|
});
|
|
642
|
-
|
|
643
|
-
super(address, abi, contractRunner);
|
|
613
|
+
super(address, abi, runner);
|
|
644
614
|
const baseProvider = runner.baseProvider || runner.provider?.baseProvider;
|
|
645
615
|
if (typeof baseProvider?.setContract === "function") {
|
|
646
616
|
baseProvider.setContract(this, contractMethodsToSign);
|
|
@@ -669,6 +639,7 @@ function calculateEventTypeHash(eventSignature) {
|
|
|
669
639
|
HEADER_EIP712_DELEGATE_SIGNATURE,
|
|
670
640
|
HEADER_EIP712_SIGNATURE,
|
|
671
641
|
HEADER_SIGNATURE,
|
|
642
|
+
HEADER_SIGNER_SWC,
|
|
672
643
|
HEADER_TIMESTAMP,
|
|
673
644
|
NetworkName,
|
|
674
645
|
PRIVATE_EVENT_SIGNATURE,
|
package/dist/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
HEADER_EIP712_DELEGATE_SIGNATURE,
|
|
10
10
|
HEADER_EIP712_SIGNATURE,
|
|
11
11
|
HEADER_SIGNATURE,
|
|
12
|
+
HEADER_SIGNER_SWC,
|
|
12
13
|
HEADER_TIMESTAMP,
|
|
13
14
|
NetworkName,
|
|
14
15
|
PRIVATE_EVENT_SIGNATURE,
|
|
@@ -26,7 +27,7 @@ import {
|
|
|
26
27
|
getAuthHeaders,
|
|
27
28
|
isSignableContractCall,
|
|
28
29
|
prepareTypedDataPayload
|
|
29
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-5JD3GAHS.mjs";
|
|
30
31
|
export {
|
|
31
32
|
ChainId,
|
|
32
33
|
DEBUG_NAMESPACE,
|
|
@@ -38,6 +39,7 @@ export {
|
|
|
38
39
|
HEADER_EIP712_DELEGATE_SIGNATURE,
|
|
39
40
|
HEADER_EIP712_SIGNATURE,
|
|
40
41
|
HEADER_SIGNATURE,
|
|
42
|
+
HEADER_SIGNER_SWC,
|
|
41
43
|
HEADER_TIMESTAMP,
|
|
42
44
|
NetworkName,
|
|
43
45
|
PRIVATE_EVENT_SIGNATURE,
|
package/dist/tests.d.mts
CHANGED
package/dist/tests.d.ts
CHANGED
package/dist/tests.js
CHANGED
|
@@ -86,6 +86,8 @@ function createCustomRpcServer(callback) {
|
|
|
86
86
|
};
|
|
87
87
|
if (requestBody.method === "eth_chainId") {
|
|
88
88
|
responseBody.result = `0x${CHAIN_ID.toString(16)}`;
|
|
89
|
+
} else if (requestBody.method === "eth_getTransactionReceipt") {
|
|
90
|
+
responseBody.result = null;
|
|
89
91
|
} else {
|
|
90
92
|
responseBody.result = "0x0";
|
|
91
93
|
}
|
package/dist/tests.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-5JD3GAHS.mjs";
|
|
2
2
|
|
|
3
3
|
// tests/utils/mocked-custom-grpc.ts
|
|
4
4
|
import http from "http";
|
|
@@ -27,6 +27,8 @@ function createCustomRpcServer(callback) {
|
|
|
27
27
|
};
|
|
28
28
|
if (requestBody.method === "eth_chainId") {
|
|
29
29
|
responseBody.result = `0x${CHAIN_ID.toString(16)}`;
|
|
30
|
+
} else if (requestBody.method === "eth_getTransactionReceipt") {
|
|
31
|
+
responseBody.result = null;
|
|
30
32
|
} else {
|
|
31
33
|
responseBody.result = "0x0";
|
|
32
34
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appliedblockchain/silentdatarollup-core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Core library for Silent Data
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "Core library for Silent Data",
|
|
5
5
|
"author": "Applied Blockchain",
|
|
6
6
|
"homepage": "https://github.com/appliedblockchain/silent-data-rollup-providers#readme",
|
|
7
7
|
"keywords": [
|