@appliedblockchain/silentdatarollup-core 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BIZ7KJDG.mjs → chunk-LT2HDZHC.mjs} +26 -10
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +24 -9
- package/dist/index.mjs +1 -1
- package/dist/tests.mjs +1 -1
- package/package.json +1 -1
|
@@ -495,20 +495,39 @@ var SilentDataRollupBase = class {
|
|
|
495
495
|
// src/contract.ts
|
|
496
496
|
import {
|
|
497
497
|
Contract as Contract2,
|
|
498
|
-
Interface
|
|
498
|
+
Interface,
|
|
499
|
+
assertArgument
|
|
499
500
|
} from "ethers";
|
|
500
501
|
var CustomContractRunner = class {
|
|
501
|
-
constructor(signer) {
|
|
502
|
-
this.provider =
|
|
502
|
+
constructor(provider, signer) {
|
|
503
|
+
this.provider = provider;
|
|
503
504
|
this.signer = signer;
|
|
504
505
|
}
|
|
505
506
|
async sendTransaction(tx) {
|
|
506
|
-
|
|
507
|
+
const signerAddress = await this.signer.getAddress();
|
|
508
|
+
const latestNonce = await this.provider.getTransactionCount(
|
|
509
|
+
signerAddress,
|
|
510
|
+
"latest"
|
|
511
|
+
);
|
|
512
|
+
tx.nonce = latestNonce;
|
|
507
513
|
return this.signer.sendTransaction(tx);
|
|
508
514
|
}
|
|
509
515
|
};
|
|
516
|
+
function getContractRunner(runner, provider) {
|
|
517
|
+
const runnerIsSigner = typeof runner.sendTransaction === "function";
|
|
518
|
+
if (!runnerIsSigner) {
|
|
519
|
+
return runner;
|
|
520
|
+
}
|
|
521
|
+
const runnerProviderConstructor = runner.provider?.constructor.name ?? "";
|
|
522
|
+
if (!runnerProviderConstructor.includes("SilentDataRollupProvider")) {
|
|
523
|
+
assertArgument(provider, "provider is mandatory", "provider", provider);
|
|
524
|
+
return new CustomContractRunner(provider, runner);
|
|
525
|
+
}
|
|
526
|
+
return new CustomContractRunner(runner.provider, runner);
|
|
527
|
+
}
|
|
510
528
|
var SilentDataRollupContract = class extends Contract2 {
|
|
511
|
-
constructor(
|
|
529
|
+
constructor(config) {
|
|
530
|
+
const { address, abi, runner, contractMethodsToSign, provider } = config;
|
|
512
531
|
const contractInterface = new Interface(abi);
|
|
513
532
|
contractMethodsToSign.forEach((method) => {
|
|
514
533
|
if (!contractInterface.hasFunction(method)) {
|
|
@@ -517,12 +536,9 @@ var SilentDataRollupContract = class extends Contract2 {
|
|
|
517
536
|
);
|
|
518
537
|
}
|
|
519
538
|
});
|
|
539
|
+
const contractRunner = getContractRunner(runner, provider);
|
|
540
|
+
super(address, abi, contractRunner);
|
|
520
541
|
const baseProvider = runner.baseProvider || runner.provider?.baseProvider;
|
|
521
|
-
const runnerIsSigner = typeof runner.sendTransaction === "function";
|
|
522
|
-
if (runnerIsSigner) {
|
|
523
|
-
runner = new CustomContractRunner(runner);
|
|
524
|
-
}
|
|
525
|
-
super(address, abi, runner);
|
|
526
542
|
if (typeof baseProvider?.setContract === "function") {
|
|
527
543
|
baseProvider.setContract(this, contractMethodsToSign);
|
|
528
544
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer, JsonRpcPayload,
|
|
1
|
+
import { Signer, JsonRpcPayload, InterfaceAbi, ContractRunner, Provider, Contract, TypedDataDomain, TypedDataField } from 'ethers';
|
|
2
2
|
|
|
3
3
|
declare const SIGN_RPC_METHODS: string[];
|
|
4
4
|
declare const eip721Domain: {
|
|
@@ -94,6 +94,13 @@ type DelegateHeaders = {
|
|
|
94
94
|
[HEADER_DELEGATE_SIGNATURE]?: string;
|
|
95
95
|
[HEADER_EIP712_DELEGATE_SIGNATURE]?: string;
|
|
96
96
|
};
|
|
97
|
+
type SilentDataRollupContractConfig = {
|
|
98
|
+
address: string;
|
|
99
|
+
abi: InterfaceAbi;
|
|
100
|
+
runner: ContractRunner;
|
|
101
|
+
contractMethodsToSign: string[];
|
|
102
|
+
provider?: Provider;
|
|
103
|
+
};
|
|
97
104
|
|
|
98
105
|
declare class SilentDataRollupBase {
|
|
99
106
|
config: BaseConfig;
|
|
@@ -158,7 +165,7 @@ declare class SilentDataRollupBase {
|
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
declare class SilentDataRollupContract extends Contract {
|
|
161
|
-
constructor(
|
|
168
|
+
constructor(config: SilentDataRollupContractConfig);
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
declare function getAuthEIP721Types(payload: JsonRpcPayload | JsonRpcPayload[]): {
|
|
@@ -202,4 +209,4 @@ declare function isSignableContractCall(payload: JsonRpcPayload, contractMethods
|
|
|
202
209
|
declare const defaultGetDelegate: (provider: any) => Promise<Signer>;
|
|
203
210
|
declare const prepareTypedDataPayload: (p: JsonRpcPayload) => AuthSignatureMessageRequest;
|
|
204
211
|
|
|
205
|
-
export { type AuthHeaders, type AuthSignatureMessage, type AuthSignatureMessageRequest, type BaseConfig, ChainId, 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, SIGN_RPC_METHODS, SignatureType, type SilentDataProviderOptions, SilentDataRollupBase, SilentDataRollupContract, type SilentdataNetworkConfig, WHITELISTED_METHODS, defaultGetDelegate, delegateEIP721Types, eip721Domain, getAuthEIP721Types, getAuthHeaders, isSignableContractCall, prepareTypedDataPayload, signAuthHeaderRawMessage, signAuthHeaderTypedData, signRawDelegateHeader, signTypedDelegateHeader };
|
|
212
|
+
export { type AuthHeaders, type AuthSignatureMessage, type AuthSignatureMessageRequest, type BaseConfig, ChainId, 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, SIGN_RPC_METHODS, SignatureType, type SilentDataProviderOptions, SilentDataRollupBase, SilentDataRollupContract, type SilentDataRollupContractConfig, type SilentdataNetworkConfig, WHITELISTED_METHODS, defaultGetDelegate, delegateEIP721Types, eip721Domain, getAuthEIP721Types, getAuthHeaders, isSignableContractCall, prepareTypedDataPayload, signAuthHeaderRawMessage, signAuthHeaderTypedData, signRawDelegateHeader, signTypedDelegateHeader };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer, JsonRpcPayload,
|
|
1
|
+
import { Signer, JsonRpcPayload, InterfaceAbi, ContractRunner, Provider, Contract, TypedDataDomain, TypedDataField } from 'ethers';
|
|
2
2
|
|
|
3
3
|
declare const SIGN_RPC_METHODS: string[];
|
|
4
4
|
declare const eip721Domain: {
|
|
@@ -94,6 +94,13 @@ type DelegateHeaders = {
|
|
|
94
94
|
[HEADER_DELEGATE_SIGNATURE]?: string;
|
|
95
95
|
[HEADER_EIP712_DELEGATE_SIGNATURE]?: string;
|
|
96
96
|
};
|
|
97
|
+
type SilentDataRollupContractConfig = {
|
|
98
|
+
address: string;
|
|
99
|
+
abi: InterfaceAbi;
|
|
100
|
+
runner: ContractRunner;
|
|
101
|
+
contractMethodsToSign: string[];
|
|
102
|
+
provider?: Provider;
|
|
103
|
+
};
|
|
97
104
|
|
|
98
105
|
declare class SilentDataRollupBase {
|
|
99
106
|
config: BaseConfig;
|
|
@@ -158,7 +165,7 @@ declare class SilentDataRollupBase {
|
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
declare class SilentDataRollupContract extends Contract {
|
|
161
|
-
constructor(
|
|
168
|
+
constructor(config: SilentDataRollupContractConfig);
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
declare function getAuthEIP721Types(payload: JsonRpcPayload | JsonRpcPayload[]): {
|
|
@@ -202,4 +209,4 @@ declare function isSignableContractCall(payload: JsonRpcPayload, contractMethods
|
|
|
202
209
|
declare const defaultGetDelegate: (provider: any) => Promise<Signer>;
|
|
203
210
|
declare const prepareTypedDataPayload: (p: JsonRpcPayload) => AuthSignatureMessageRequest;
|
|
204
211
|
|
|
205
|
-
export { type AuthHeaders, type AuthSignatureMessage, type AuthSignatureMessageRequest, type BaseConfig, ChainId, 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, SIGN_RPC_METHODS, SignatureType, type SilentDataProviderOptions, SilentDataRollupBase, SilentDataRollupContract, type SilentdataNetworkConfig, WHITELISTED_METHODS, defaultGetDelegate, delegateEIP721Types, eip721Domain, getAuthEIP721Types, getAuthHeaders, isSignableContractCall, prepareTypedDataPayload, signAuthHeaderRawMessage, signAuthHeaderTypedData, signRawDelegateHeader, signTypedDelegateHeader };
|
|
212
|
+
export { type AuthHeaders, type AuthSignatureMessage, type AuthSignatureMessageRequest, type BaseConfig, ChainId, 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, SIGN_RPC_METHODS, SignatureType, type SilentDataProviderOptions, SilentDataRollupBase, SilentDataRollupContract, type SilentDataRollupContractConfig, type SilentdataNetworkConfig, WHITELISTED_METHODS, defaultGetDelegate, delegateEIP721Types, eip721Domain, getAuthEIP721Types, getAuthHeaders, isSignableContractCall, prepareTypedDataPayload, signAuthHeaderRawMessage, signAuthHeaderTypedData, signRawDelegateHeader, signTypedDelegateHeader };
|
package/dist/index.js
CHANGED
|
@@ -558,17 +558,35 @@ var SilentDataRollupBase = class {
|
|
|
558
558
|
// src/contract.ts
|
|
559
559
|
var import_ethers2 = require("ethers");
|
|
560
560
|
var CustomContractRunner = class {
|
|
561
|
-
constructor(signer) {
|
|
562
|
-
this.provider =
|
|
561
|
+
constructor(provider, signer) {
|
|
562
|
+
this.provider = provider;
|
|
563
563
|
this.signer = signer;
|
|
564
564
|
}
|
|
565
565
|
async sendTransaction(tx) {
|
|
566
|
-
|
|
566
|
+
const signerAddress = await this.signer.getAddress();
|
|
567
|
+
const latestNonce = await this.provider.getTransactionCount(
|
|
568
|
+
signerAddress,
|
|
569
|
+
"latest"
|
|
570
|
+
);
|
|
571
|
+
tx.nonce = latestNonce;
|
|
567
572
|
return this.signer.sendTransaction(tx);
|
|
568
573
|
}
|
|
569
574
|
};
|
|
575
|
+
function getContractRunner(runner, provider) {
|
|
576
|
+
const runnerIsSigner = typeof runner.sendTransaction === "function";
|
|
577
|
+
if (!runnerIsSigner) {
|
|
578
|
+
return runner;
|
|
579
|
+
}
|
|
580
|
+
const runnerProviderConstructor = runner.provider?.constructor.name ?? "";
|
|
581
|
+
if (!runnerProviderConstructor.includes("SilentDataRollupProvider")) {
|
|
582
|
+
(0, import_ethers2.assertArgument)(provider, "provider is mandatory", "provider", provider);
|
|
583
|
+
return new CustomContractRunner(provider, runner);
|
|
584
|
+
}
|
|
585
|
+
return new CustomContractRunner(runner.provider, runner);
|
|
586
|
+
}
|
|
570
587
|
var SilentDataRollupContract = class extends import_ethers2.Contract {
|
|
571
|
-
constructor(
|
|
588
|
+
constructor(config) {
|
|
589
|
+
const { address, abi, runner, contractMethodsToSign, provider } = config;
|
|
572
590
|
const contractInterface = new import_ethers2.Interface(abi);
|
|
573
591
|
contractMethodsToSign.forEach((method) => {
|
|
574
592
|
if (!contractInterface.hasFunction(method)) {
|
|
@@ -577,12 +595,9 @@ var SilentDataRollupContract = class extends import_ethers2.Contract {
|
|
|
577
595
|
);
|
|
578
596
|
}
|
|
579
597
|
});
|
|
598
|
+
const contractRunner = getContractRunner(runner, provider);
|
|
599
|
+
super(address, abi, contractRunner);
|
|
580
600
|
const baseProvider = runner.baseProvider || runner.provider?.baseProvider;
|
|
581
|
-
const runnerIsSigner = typeof runner.sendTransaction === "function";
|
|
582
|
-
if (runnerIsSigner) {
|
|
583
|
-
runner = new CustomContractRunner(runner);
|
|
584
|
-
}
|
|
585
|
-
super(address, abi, runner);
|
|
586
601
|
if (typeof baseProvider?.setContract === "function") {
|
|
587
602
|
baseProvider.setContract(this, contractMethodsToSign);
|
|
588
603
|
}
|
package/dist/index.mjs
CHANGED
package/dist/tests.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appliedblockchain/silentdatarollup-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Core library for Silent Data [Rollup]",
|
|
5
5
|
"author": "Applied Blockchain",
|
|
6
6
|
"homepage": "https://github.com/appliedblockchain/silent-data-rollup-providers#readme",
|