@appliedblockchain/silentdatarollup-core 1.0.7 → 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-5VQIOQAW.mjs → chunk-5JD3GAHS.mjs} +5 -32
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -27
- package/dist/index.mjs +3 -1
- package/dist/tests.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ var HEADER_EIP712_SIGNATURE = "x-eip712-signature";
|
|
|
26
26
|
var HEADER_DELEGATE = "x-delegate";
|
|
27
27
|
var HEADER_DELEGATE_SIGNATURE = "x-delegate-signature";
|
|
28
28
|
var HEADER_EIP712_DELEGATE_SIGNATURE = "x-eip712-delegate-signature";
|
|
29
|
+
var HEADER_SIGNER_SWC = "x-signer-swc";
|
|
29
30
|
var DEFAULT_DELEGATE_EXPIRES = 10 * 60 * 60;
|
|
30
31
|
var DELEGATE_EXPIRATION_THRESHOLD_BUFFER = 5;
|
|
31
32
|
var WHITELISTED_METHODS = [
|
|
@@ -534,38 +535,10 @@ var SilentDataRollupBase = class {
|
|
|
534
535
|
};
|
|
535
536
|
|
|
536
537
|
// src/contract.ts
|
|
537
|
-
import {
|
|
538
|
-
Contract,
|
|
539
|
-
Interface,
|
|
540
|
-
assertArgument
|
|
541
|
-
} from "ethers";
|
|
542
|
-
var CustomContractRunner = class {
|
|
543
|
-
constructor(provider, signer) {
|
|
544
|
-
this.provider = provider;
|
|
545
|
-
this.signer = signer;
|
|
546
|
-
}
|
|
547
|
-
async sendTransaction(tx) {
|
|
548
|
-
if (!tx.gasLimit) {
|
|
549
|
-
tx.gasLimit = await this.provider.estimateGas(tx);
|
|
550
|
-
}
|
|
551
|
-
return this.signer.sendTransaction(tx);
|
|
552
|
-
}
|
|
553
|
-
};
|
|
554
|
-
function getContractRunner(runner, provider) {
|
|
555
|
-
const runnerIsSigner = typeof runner.sendTransaction === "function";
|
|
556
|
-
if (!runnerIsSigner) {
|
|
557
|
-
return runner;
|
|
558
|
-
}
|
|
559
|
-
const runnerProviderConstructor = runner.provider?.constructor.name ?? "";
|
|
560
|
-
if (!runnerProviderConstructor.includes("SilentDataRollupProvider")) {
|
|
561
|
-
assertArgument(provider, "provider is mandatory", "provider", provider);
|
|
562
|
-
return new CustomContractRunner(provider, runner);
|
|
563
|
-
}
|
|
564
|
-
return new CustomContractRunner(runner.provider, runner);
|
|
565
|
-
}
|
|
538
|
+
import { Contract, Interface } from "ethers";
|
|
566
539
|
var SilentDataRollupContract = class extends Contract {
|
|
567
540
|
constructor(config) {
|
|
568
|
-
const { address, abi, runner, contractMethodsToSign
|
|
541
|
+
const { address, abi, runner, contractMethodsToSign } = config;
|
|
569
542
|
const contractInterface = new Interface(abi);
|
|
570
543
|
contractMethodsToSign.forEach((method) => {
|
|
571
544
|
if (!contractInterface.hasFunction(method)) {
|
|
@@ -574,8 +547,7 @@ var SilentDataRollupContract = class extends Contract {
|
|
|
574
547
|
);
|
|
575
548
|
}
|
|
576
549
|
});
|
|
577
|
-
|
|
578
|
-
super(address, abi, contractRunner);
|
|
550
|
+
super(address, abi, runner);
|
|
579
551
|
const baseProvider = runner.baseProvider || runner.provider?.baseProvider;
|
|
580
552
|
if (typeof baseProvider?.setContract === "function") {
|
|
581
553
|
baseProvider.setContract(this, contractMethodsToSign);
|
|
@@ -605,6 +577,7 @@ export {
|
|
|
605
577
|
HEADER_DELEGATE,
|
|
606
578
|
HEADER_DELEGATE_SIGNATURE,
|
|
607
579
|
HEADER_EIP712_DELEGATE_SIGNATURE,
|
|
580
|
+
HEADER_SIGNER_SWC,
|
|
608
581
|
DEFAULT_DELEGATE_EXPIRES,
|
|
609
582
|
DELEGATE_EXPIRATION_THRESHOLD_BUFFER,
|
|
610
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,
|
|
@@ -88,6 +89,7 @@ var HEADER_EIP712_SIGNATURE = "x-eip712-signature";
|
|
|
88
89
|
var HEADER_DELEGATE = "x-delegate";
|
|
89
90
|
var HEADER_DELEGATE_SIGNATURE = "x-delegate-signature";
|
|
90
91
|
var HEADER_EIP712_DELEGATE_SIGNATURE = "x-eip712-delegate-signature";
|
|
92
|
+
var HEADER_SIGNER_SWC = "x-signer-swc";
|
|
91
93
|
var DEFAULT_DELEGATE_EXPIRES = 10 * 60 * 60;
|
|
92
94
|
var DELEGATE_EXPIRATION_THRESHOLD_BUFFER = 5;
|
|
93
95
|
var WHITELISTED_METHODS = [
|
|
@@ -597,33 +599,9 @@ var SilentDataRollupBase = class {
|
|
|
597
599
|
|
|
598
600
|
// src/contract.ts
|
|
599
601
|
var import_ethers2 = require("ethers");
|
|
600
|
-
var CustomContractRunner = class {
|
|
601
|
-
constructor(provider, signer) {
|
|
602
|
-
this.provider = provider;
|
|
603
|
-
this.signer = signer;
|
|
604
|
-
}
|
|
605
|
-
async sendTransaction(tx) {
|
|
606
|
-
if (!tx.gasLimit) {
|
|
607
|
-
tx.gasLimit = await this.provider.estimateGas(tx);
|
|
608
|
-
}
|
|
609
|
-
return this.signer.sendTransaction(tx);
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
function getContractRunner(runner, provider) {
|
|
613
|
-
const runnerIsSigner = typeof runner.sendTransaction === "function";
|
|
614
|
-
if (!runnerIsSigner) {
|
|
615
|
-
return runner;
|
|
616
|
-
}
|
|
617
|
-
const runnerProviderConstructor = runner.provider?.constructor.name ?? "";
|
|
618
|
-
if (!runnerProviderConstructor.includes("SilentDataRollupProvider")) {
|
|
619
|
-
(0, import_ethers2.assertArgument)(provider, "provider is mandatory", "provider", provider);
|
|
620
|
-
return new CustomContractRunner(provider, runner);
|
|
621
|
-
}
|
|
622
|
-
return new CustomContractRunner(runner.provider, runner);
|
|
623
|
-
}
|
|
624
602
|
var SilentDataRollupContract = class extends import_ethers2.Contract {
|
|
625
603
|
constructor(config) {
|
|
626
|
-
const { address, abi, runner, contractMethodsToSign
|
|
604
|
+
const { address, abi, runner, contractMethodsToSign } = config;
|
|
627
605
|
const contractInterface = new import_ethers2.Interface(abi);
|
|
628
606
|
contractMethodsToSign.forEach((method) => {
|
|
629
607
|
if (!contractInterface.hasFunction(method)) {
|
|
@@ -632,8 +610,7 @@ var SilentDataRollupContract = class extends import_ethers2.Contract {
|
|
|
632
610
|
);
|
|
633
611
|
}
|
|
634
612
|
});
|
|
635
|
-
|
|
636
|
-
super(address, abi, contractRunner);
|
|
613
|
+
super(address, abi, runner);
|
|
637
614
|
const baseProvider = runner.baseProvider || runner.provider?.baseProvider;
|
|
638
615
|
if (typeof baseProvider?.setContract === "function") {
|
|
639
616
|
baseProvider.setContract(this, contractMethodsToSign);
|
|
@@ -662,6 +639,7 @@ function calculateEventTypeHash(eventSignature) {
|
|
|
662
639
|
HEADER_EIP712_DELEGATE_SIGNATURE,
|
|
663
640
|
HEADER_EIP712_SIGNATURE,
|
|
664
641
|
HEADER_SIGNATURE,
|
|
642
|
+
HEADER_SIGNER_SWC,
|
|
665
643
|
HEADER_TIMESTAMP,
|
|
666
644
|
NetworkName,
|
|
667
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.mjs
CHANGED
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": [
|