@partisiablockchain/blockchain-api-transaction-client 5.61.0 → 5.71.0
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/package.json +2 -1
- package/target/main/index.d.ts +2 -1
- package/target/main/index.js +3 -1
- package/target/main/index.js.map +1 -1
- package/target/main/transactionclient/BlockchainTransactionClient.d.ts +17 -7
- package/target/main/transactionclient/BlockchainTransactionClient.js +29 -18
- package/target/main/transactionclient/BlockchainTransactionClient.js.map +1 -1
- package/target/main/transactionclient/SenderAuthenticationKeyPair.js +2 -5
- package/target/main/transactionclient/SenderAuthenticationKeyPair.js.map +1 -1
- package/target/main/transactionclient/ShardAndChainControllerTransactionClient.d.ts +23 -0
- package/target/main/transactionclient/ShardAndChainControllerTransactionClient.js +69 -0
- package/target/main/transactionclient/ShardAndChainControllerTransactionClient.js.map +1 -0
- package/target/main/transactionclient/SignedTransaction.d.ts +7 -0
- package/target/main/transactionclient/SignedTransaction.js +13 -4
- package/target/main/transactionclient/SignedTransaction.js.map +1 -1
- package/target/main/transactionclient/TransactionTree.d.ts +20 -0
- package/target/main/transactionclient/TransactionTree.js +50 -0
- package/target/main/transactionclient/TransactionTree.js.map +1 -0
- package/target/main/transactionclient/types.d.ts +36 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@partisiablockchain/blockchain-api-transaction-client",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.71.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"eslint-plugin-jsdoc": "^50.0.0",
|
|
24
24
|
"globals": "^15.0.0",
|
|
25
25
|
"jest": "^29.7.0",
|
|
26
|
+
"prettier": "3.4.2",
|
|
26
27
|
"ts-jest": "^29.1.1",
|
|
27
28
|
"typescript": "^5.4.5"
|
|
28
29
|
},
|
package/target/main/index.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export * from "./generated/openapi/models/index";
|
|
|
4
4
|
export { BlockchainTransactionClient } from "./transactionclient/BlockchainTransactionClient";
|
|
5
5
|
export { SignedTransaction } from "./transactionclient/SignedTransaction";
|
|
6
6
|
export { SenderAuthenticationKeyPair } from "./transactionclient/SenderAuthenticationKeyPair";
|
|
7
|
-
export { Transaction,
|
|
7
|
+
export { Transaction, SentTransaction, SenderAuthentication, Hash, BlockchainAddress, Signature, BlockchainClientForTransaction, } from "./transactionclient/types";
|
|
8
8
|
export { ConditionWaiter, ConditionWaiterImpl } from "./transactionclient/ConditionWaiter";
|
|
9
|
+
export { TransactionTree } from "./transactionclient/TransactionTree";
|
package/target/main/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
31
31
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
32
32
|
};
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.ConditionWaiterImpl = exports.SenderAuthenticationKeyPair = exports.SignedTransaction = exports.BlockchainTransactionClient = void 0;
|
|
34
|
+
exports.TransactionTree = exports.ConditionWaiterImpl = exports.SenderAuthenticationKeyPair = exports.SignedTransaction = exports.BlockchainTransactionClient = void 0;
|
|
35
35
|
__exportStar(require("./generated/openapi/runtime"), exports);
|
|
36
36
|
__exportStar(require("./generated/openapi/apis/index"), exports);
|
|
37
37
|
__exportStar(require("./generated/openapi/models/index"), exports);
|
|
@@ -43,4 +43,6 @@ var SenderAuthenticationKeyPair_1 = require("./transactionclient/SenderAuthentic
|
|
|
43
43
|
Object.defineProperty(exports, "SenderAuthenticationKeyPair", { enumerable: true, get: function () { return SenderAuthenticationKeyPair_1.SenderAuthenticationKeyPair; } });
|
|
44
44
|
var ConditionWaiter_1 = require("./transactionclient/ConditionWaiter");
|
|
45
45
|
Object.defineProperty(exports, "ConditionWaiterImpl", { enumerable: true, get: function () { return ConditionWaiter_1.ConditionWaiterImpl; } });
|
|
46
|
+
var TransactionTree_1 = require("./transactionclient/TransactionTree");
|
|
47
|
+
Object.defineProperty(exports, "TransactionTree", { enumerable: true, get: function () { return TransactionTree_1.TransactionTree; } });
|
|
46
48
|
//# sourceMappingURL=index.js.map
|
package/target/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;;AAEH,8DAA4C;AAC5C,iEAA+C;AAC/C,mEAAiD;AAEjD,+FAA8F;AAArF,0IAAA,2BAA2B,OAAA;AACpC,2EAA0E;AAAjE,sHAAA,iBAAiB,OAAA;AAC1B,+FAA8F;AAArF,0IAAA,2BAA2B,OAAA;AAUpC,uEAA2F;AAAjE,sHAAA,mBAAmB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/main/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;;AAEH,8DAA4C;AAC5C,iEAA+C;AAC/C,mEAAiD;AAEjD,+FAA8F;AAArF,0IAAA,2BAA2B,OAAA;AACpC,2EAA0E;AAAjE,sHAAA,iBAAiB,OAAA;AAC1B,+FAA8F;AAArF,0IAAA,2BAA2B,OAAA;AAUpC,uEAA2F;AAAjE,sHAAA,mBAAmB,OAAA;AAC7C,uEAAsE;AAA7D,kHAAA,eAAe,OAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { SenderAuthentication, SentTransaction, Transaction
|
|
2
|
-
import {
|
|
1
|
+
import { BlockchainClientForTransaction, SenderAuthentication, SentTransaction, Transaction } from "./types";
|
|
2
|
+
import { ExecutedTransaction } from "../generated/openapi";
|
|
3
3
|
import { ConditionWaiter } from "./ConditionWaiter";
|
|
4
4
|
import { SignedTransaction } from "./SignedTransaction";
|
|
5
|
+
import { TransactionTree } from "./TransactionTree";
|
|
5
6
|
/** A client that supports signing, sending and waiting for transactions on the blockchain. */
|
|
6
7
|
export declare class BlockchainTransactionClient {
|
|
7
8
|
private readonly authentication;
|
|
8
|
-
private readonly
|
|
9
|
-
private readonly shardController;
|
|
9
|
+
private readonly transactionClient;
|
|
10
10
|
private readonly transactionValidityDuration;
|
|
11
11
|
private readonly spawnedEventTimeout;
|
|
12
12
|
private readonly currentTime;
|
|
@@ -37,10 +37,20 @@ export declare class BlockchainTransactionClient {
|
|
|
37
37
|
* @returns A blockchain transaction client
|
|
38
38
|
*/
|
|
39
39
|
static create(baseUrl: string, authentication: SenderAuthentication, transactionValidityInMillis?: number, spawnedEventTimeoutInMillis?: number): BlockchainTransactionClient;
|
|
40
|
+
/**
|
|
41
|
+
* Create a blockchain transaction client for a custom API.
|
|
42
|
+
* @param transactionClient the client used for communicating with the blockchain api
|
|
43
|
+
* @param authentication authentication of the sender that will sign transactions
|
|
44
|
+
* @param transactionValidityInMillis the number of milliseconds a signed transaction is valid for
|
|
45
|
+
* inclusion in a block.
|
|
46
|
+
* @param spawnedEventTimeoutInMillis the number of milliseconds the client will wait for a
|
|
47
|
+
* spawned event to be included in a block before timing out.
|
|
48
|
+
* @returns A blockchain transaction client
|
|
49
|
+
*/
|
|
50
|
+
static createForCustomApi(transactionClient: BlockchainClientForTransaction, authentication: SenderAuthentication, transactionValidityInMillis?: number, spawnedEventTimeoutInMillis?: number): BlockchainTransactionClient;
|
|
40
51
|
/**
|
|
41
52
|
* Create a blockchain transaction client used for testing.
|
|
42
|
-
* @param
|
|
43
|
-
* @param shardController the client used for communicating with the shard api
|
|
53
|
+
* @param transactionClient the client used for communicating with the blockchain api
|
|
44
54
|
* @param authentication authentication of the sender that will sign transactions
|
|
45
55
|
* @param transactionValidityDuration the number of milliseconds a signed transaction is valid for
|
|
46
56
|
* inclusion in a block.
|
|
@@ -50,7 +60,7 @@ export declare class BlockchainTransactionClient {
|
|
|
50
60
|
* @param conditionWaiter support for injecting custom condition waiter
|
|
51
61
|
* @returns A blockchain transaction client
|
|
52
62
|
*/
|
|
53
|
-
static createForTest(
|
|
63
|
+
static createForTest(transactionClient: BlockchainClientForTransaction, authentication: SenderAuthentication, transactionValidityDuration: number, spawnedEventTimeout: number, currentTime: () => number, conditionWaiter: ConditionWaiter): BlockchainTransactionClient;
|
|
54
64
|
/**
|
|
55
65
|
* Sign a transaction in preparation for sending it to the blockchain. The signed transaction
|
|
56
66
|
* expires after {@link #transactionValidityDuration} millis or if the nonce of the signer
|
|
@@ -30,12 +30,13 @@ exports.BlockchainTransactionClient = void 0;
|
|
|
30
30
|
const openapi_1 = require("../generated/openapi");
|
|
31
31
|
const ConditionWaiter_1 = require("./ConditionWaiter");
|
|
32
32
|
const SignedTransaction_1 = require("./SignedTransaction");
|
|
33
|
+
const ShardAndChainControllerTransactionClient_1 = require("./ShardAndChainControllerTransactionClient");
|
|
34
|
+
const TransactionTree_1 = require("./TransactionTree");
|
|
33
35
|
/** A client that supports signing, sending and waiting for transactions on the blockchain. */
|
|
34
36
|
class BlockchainTransactionClient {
|
|
35
|
-
constructor(
|
|
37
|
+
constructor(transactionClient, authentication, transactionValidityDuration, spawnedEventTimeout, currentTime, conditionWaiter) {
|
|
36
38
|
this.authentication = authentication;
|
|
37
|
-
this.
|
|
38
|
-
this.shardController = shardController;
|
|
39
|
+
this.transactionClient = transactionClient;
|
|
39
40
|
this.transactionValidityDuration = transactionValidityDuration;
|
|
40
41
|
this.spawnedEventTimeout = spawnedEventTimeout;
|
|
41
42
|
this.currentTime = currentTime;
|
|
@@ -54,12 +55,25 @@ class BlockchainTransactionClient {
|
|
|
54
55
|
static create(baseUrl, authentication, transactionValidityInMillis, spawnedEventTimeoutInMillis) {
|
|
55
56
|
const chainControllerApi = new openapi_1.ChainControllerApi(new openapi_1.Configuration({ basePath: baseUrl }));
|
|
56
57
|
const shardControllerApi = new openapi_1.ShardControllerApi(new openapi_1.Configuration({ basePath: baseUrl }));
|
|
57
|
-
|
|
58
|
+
const transactionClient = new ShardAndChainControllerTransactionClient_1.ShardAndChainControllerTransactionClient(chainControllerApi, shardControllerApi);
|
|
59
|
+
return new BlockchainTransactionClient(transactionClient, authentication, transactionValidityInMillis !== null && transactionValidityInMillis !== void 0 ? transactionValidityInMillis : this.DEFAULT_TRANSACTION_VALIDITY_DURATION, spawnedEventTimeoutInMillis !== null && spawnedEventTimeoutInMillis !== void 0 ? spawnedEventTimeoutInMillis : this.DEFAULT_SPAWNED_EVENT_TIMEOUT, this.DEFAULT_CURRENT_TIME, ConditionWaiter_1.ConditionWaiterImpl.create());
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a blockchain transaction client for a custom API.
|
|
63
|
+
* @param transactionClient the client used for communicating with the blockchain api
|
|
64
|
+
* @param authentication authentication of the sender that will sign transactions
|
|
65
|
+
* @param transactionValidityInMillis the number of milliseconds a signed transaction is valid for
|
|
66
|
+
* inclusion in a block.
|
|
67
|
+
* @param spawnedEventTimeoutInMillis the number of milliseconds the client will wait for a
|
|
68
|
+
* spawned event to be included in a block before timing out.
|
|
69
|
+
* @returns A blockchain transaction client
|
|
70
|
+
*/
|
|
71
|
+
static createForCustomApi(transactionClient, authentication, transactionValidityInMillis, spawnedEventTimeoutInMillis) {
|
|
72
|
+
return new BlockchainTransactionClient(transactionClient, authentication, transactionValidityInMillis !== null && transactionValidityInMillis !== void 0 ? transactionValidityInMillis : this.DEFAULT_TRANSACTION_VALIDITY_DURATION, spawnedEventTimeoutInMillis !== null && spawnedEventTimeoutInMillis !== void 0 ? spawnedEventTimeoutInMillis : this.DEFAULT_SPAWNED_EVENT_TIMEOUT, this.DEFAULT_CURRENT_TIME, ConditionWaiter_1.ConditionWaiterImpl.create());
|
|
58
73
|
}
|
|
59
74
|
/**
|
|
60
75
|
* Create a blockchain transaction client used for testing.
|
|
61
|
-
* @param
|
|
62
|
-
* @param shardController the client used for communicating with the shard api
|
|
76
|
+
* @param transactionClient the client used for communicating with the blockchain api
|
|
63
77
|
* @param authentication authentication of the sender that will sign transactions
|
|
64
78
|
* @param transactionValidityDuration the number of milliseconds a signed transaction is valid for
|
|
65
79
|
* inclusion in a block.
|
|
@@ -69,8 +83,8 @@ class BlockchainTransactionClient {
|
|
|
69
83
|
* @param conditionWaiter support for injecting custom condition waiter
|
|
70
84
|
* @returns A blockchain transaction client
|
|
71
85
|
*/
|
|
72
|
-
static createForTest(
|
|
73
|
-
return new BlockchainTransactionClient(
|
|
86
|
+
static createForTest(transactionClient, authentication, transactionValidityDuration, spawnedEventTimeout, currentTime, conditionWaiter) {
|
|
87
|
+
return new BlockchainTransactionClient(transactionClient, authentication, transactionValidityDuration, spawnedEventTimeout, currentTime, conditionWaiter);
|
|
74
88
|
}
|
|
75
89
|
/**
|
|
76
90
|
* Sign a transaction in preparation for sending it to the blockchain. The signed transaction
|
|
@@ -84,8 +98,8 @@ class BlockchainTransactionClient {
|
|
|
84
98
|
sign(transaction, gasCost, applicableUntil) {
|
|
85
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
100
|
const sender = this.authentication.getAddress();
|
|
87
|
-
const nonce =
|
|
88
|
-
const chainId =
|
|
101
|
+
const nonce = yield this.transactionClient.getNonce(sender);
|
|
102
|
+
const chainId = yield this.transactionClient.getChainId();
|
|
89
103
|
let validToTime = this.currentTime() + this.transactionValidityDuration;
|
|
90
104
|
if (applicableUntil !== undefined) {
|
|
91
105
|
validToTime = Math.min(validToTime, applicableUntil);
|
|
@@ -102,7 +116,7 @@ class BlockchainTransactionClient {
|
|
|
102
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
117
|
const bytes = signedTransaction.serialize();
|
|
104
118
|
const serializedTransaction = { payload: bytes.toString("base64") };
|
|
105
|
-
const transactionPointer = yield this.
|
|
119
|
+
const transactionPointer = yield this.transactionClient.putTransaction(serializedTransaction);
|
|
106
120
|
return { signedTransaction, transactionPointer };
|
|
107
121
|
});
|
|
108
122
|
}
|
|
@@ -155,7 +169,7 @@ class BlockchainTransactionClient {
|
|
|
155
169
|
const executedExecutionStatus = executed.executionStatus;
|
|
156
170
|
pendingEvents.push(...executedExecutionStatus.events);
|
|
157
171
|
}
|
|
158
|
-
return
|
|
172
|
+
return new TransactionTree_1.TransactionTree(executedTransaction, events);
|
|
159
173
|
});
|
|
160
174
|
}
|
|
161
175
|
/**
|
|
@@ -206,14 +220,11 @@ class BlockchainTransactionClient {
|
|
|
206
220
|
const shardId = sentTransaction.transactionPointer.destinationShardId;
|
|
207
221
|
const validToTime = sentTransaction.signedTransaction.getValidToTime();
|
|
208
222
|
const timeOut = latestBlockWait + validToTime;
|
|
209
|
-
yield this.conditionWaiter.waitForCondition(() => __awaiter(this, void 0, void 0, function* () { return
|
|
223
|
+
yield this.conditionWaiter.waitForCondition(() => __awaiter(this, void 0, void 0, function* () { return yield this.transactionClient.getLatestProductionTime(shardId); }), (productionTime) => productionTime > validToTime, timeOut, () => `Unable to get block with production time greater than ${validToTime} for shard ${shardId}`);
|
|
210
224
|
const transactionIdentifier = sentTransaction.transactionPointer.identifier;
|
|
211
225
|
// Stryker disable BlockStatement
|
|
212
226
|
try {
|
|
213
|
-
return yield this.
|
|
214
|
-
shardId,
|
|
215
|
-
transactionId: transactionIdentifier,
|
|
216
|
-
});
|
|
227
|
+
return yield this.transactionClient.getTransaction(shardId, transactionIdentifier);
|
|
217
228
|
}
|
|
218
229
|
catch (_) {
|
|
219
230
|
return undefined;
|
|
@@ -222,7 +233,7 @@ class BlockchainTransactionClient {
|
|
|
222
233
|
}
|
|
223
234
|
// Stryker restore BlockStatement
|
|
224
235
|
waitForTransaction(shardId, transactionId, timeout) {
|
|
225
|
-
return this.conditionWaiter.waitForCondition(() => this.
|
|
236
|
+
return this.conditionWaiter.waitForCondition(() => this.transactionClient.getTransaction(shardId, transactionId), (value) => value.executionStatus !== undefined && value.executionStatus.finalized, timeout, () => `Transaction '${transactionId}' was not included in a block at shard '${shardId}'`);
|
|
226
237
|
}
|
|
227
238
|
}
|
|
228
239
|
exports.BlockchainTransactionClient = BlockchainTransactionClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockchainTransactionClient.js","sourceRoot":"","sources":["../../../src/main/transactionclient/BlockchainTransactionClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"BlockchainTransactionClient.js","sourceRoot":"","sources":["../../../src/main/transactionclient/BlockchainTransactionClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;AASH,kDAO8B;AAC9B,uDAAyE;AACzE,2DAAwD;AACxD,yGAAsG;AACtG,uDAAoD;AAEpD,8FAA8F;AAC9F,MAAa,2BAA2B;IA2BtC,YACE,iBAAiD,EACjD,cAAoC,EACpC,2BAAmC,EACnC,mBAA2B,EAC3B,WAAyB,EACzB,eAAgC;QAEhC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;QAC/D,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,MAAM,CAClB,OAAe,EACf,cAAoC,EACpC,2BAAoC,EACpC,2BAAoC;QAEpC,MAAM,kBAAkB,GAAG,IAAI,4BAAkB,CAAC,IAAI,uBAAa,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5F,MAAM,kBAAkB,GAAG,IAAI,4BAAkB,CAAC,IAAI,uBAAa,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAC5F,MAAM,iBAAi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EAChD,OAAO,EACP,GAAG,EAAE,CACH,yDAAyD,WAAW,cAAc,OAAO,EAAE,CAC9F,CAAC;YACF,MAAM,qBAAqB,GAAG,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC;YAE5E,iCAAiC;YACjC,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;YACrF,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;KAAA;IACD,iCAAiC;IAEzB,kBAAkB,CACxB,OAAe,EACf,aAAmB,EACnB,OAAe;QAEf,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAC1C,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,CAAC,EACnE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,eAAe,KAAK,SAAS,IAAI,KAAK,CAAC,eAAe,CAAC,SAAS,EACjF,OAAO,EACP,GAAG,EAAE,CAAC,gBAAgB,aAAa,2CAA2C,OAAO,GAAG,CACzF,CAAC;IACJ,CAAC;;AA9TH,kEA+TC;AArTC;;;GAGG;AACoB,iEAAqC,GAAG,MAAM,CAAC;AAEtE;;;GAGG;AACoB,yDAA6B,GAAG,MAAM,CAAC;AAE9D;;GAEG;AACoB,gDAAoB,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC"}
|
|
@@ -28,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.SenderAuthenticationKeyPair = void 0;
|
|
30
30
|
const CryptoUtils_1 = require("../CryptoUtils");
|
|
31
|
-
const
|
|
31
|
+
const SignedTransaction_1 = require("./SignedTransaction");
|
|
32
32
|
/**
|
|
33
33
|
* Sender authentication based on a key-pair, consisting of a public and private key. The sender
|
|
34
34
|
* address is computed from the public key.
|
|
@@ -56,10 +56,7 @@ class SenderAuthenticationKeyPair {
|
|
|
56
56
|
/** @inheritDoc */
|
|
57
57
|
sign(transactionPayload, chainId) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const hash =
|
|
60
|
-
transactionPayload,
|
|
61
|
-
bitmanipulation_ts_1.BigEndianByteOutput.serialize((out) => out.writeString(chainId)),
|
|
62
|
-
]).toString("hex");
|
|
59
|
+
const hash = SignedTransaction_1.SignedTransaction.calculateHash(transactionPayload, chainId);
|
|
63
60
|
return CryptoUtils_1.CryptoUtils.signatureToBuffer(this.keyPair.sign(hash)).toString("hex");
|
|
64
61
|
});
|
|
65
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SenderAuthenticationKeyPair.js","sourceRoot":"","sources":["../../../src/main/transactionclient/SenderAuthenticationKeyPair.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;AAIH,gDAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"SenderAuthenticationKeyPair.js","sourceRoot":"","sources":["../../../src/main/transactionclient/SenderAuthenticationKeyPair.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;AAIH,gDAA6C;AAC7C,2DAAwD;AAExD;;;GAGG;AACH,MAAa,2BAA2B;IAGtC;;;OAGG;IACH,YAAmB,OAAyB;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,UAAkB;QACzC,OAAO,IAAI,2BAA2B,CAAC,yBAAW,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,kBAAkB;IACX,UAAU;QACf,OAAO,yBAAW,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED,kBAAkB;IACL,IAAI,CAAC,kBAA0B,EAAE,OAAe;;YAC3D,MAAM,IAAI,GAAG,qCAAiB,CAAC,aAAa,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;YAC1E,OAAO,yBAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAChF,CAAC;KAAA;CACF;AA9BD,kEA8BC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ChainControllerApi, ExecutedTransaction, SerializedTransaction, ShardControllerApi, TransactionPointer } from "../generated/openapi";
|
|
2
|
+
import { BlockchainAddress, BlockchainClientForTransaction } from "./types";
|
|
3
|
+
/** Transaction client using the shard and chain controller APIs. */
|
|
4
|
+
export declare class ShardAndChainControllerTransactionClient implements BlockchainClientForTransaction {
|
|
5
|
+
private readonly chainController;
|
|
6
|
+
private readonly shardController;
|
|
7
|
+
/**
|
|
8
|
+
* Create transaction client.
|
|
9
|
+
* @param chainController the client used for communicating with the chain api
|
|
10
|
+
* @param shardController the client used for communicating with the shard api
|
|
11
|
+
*/
|
|
12
|
+
constructor(chainController: ChainControllerApi, shardController: ShardControllerApi);
|
|
13
|
+
/** @inheritDoc */
|
|
14
|
+
getChainId(): Promise<string>;
|
|
15
|
+
/** @inheritDoc */
|
|
16
|
+
getNonce(blockchainAddress: BlockchainAddress): Promise<number>;
|
|
17
|
+
/** @inheritDoc */
|
|
18
|
+
getTransaction(shardId: string, transactionId: string): Promise<ExecutedTransaction>;
|
|
19
|
+
/** @inheritDoc */
|
|
20
|
+
getLatestProductionTime(shardId: string): Promise<number>;
|
|
21
|
+
/** @inheritDoc */
|
|
22
|
+
putTransaction(serializedTransaction: SerializedTransaction): Promise<TransactionPointer>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2022 - 2023 Partisia Blockchain Foundation
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ShardAndChainControllerTransactionClient = void 0;
|
|
30
|
+
/** Transaction client using the shard and chain controller APIs. */
|
|
31
|
+
class ShardAndChainControllerTransactionClient {
|
|
32
|
+
/**
|
|
33
|
+
* Create transaction client.
|
|
34
|
+
* @param chainController the client used for communicating with the chain api
|
|
35
|
+
* @param shardController the client used for communicating with the shard api
|
|
36
|
+
*/
|
|
37
|
+
constructor(chainController, shardController) {
|
|
38
|
+
this.chainController = chainController;
|
|
39
|
+
this.shardController = shardController;
|
|
40
|
+
}
|
|
41
|
+
/** @inheritDoc */
|
|
42
|
+
getChainId() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return (yield this.chainController.getChain()).chainId;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** @inheritDoc */
|
|
48
|
+
getNonce(blockchainAddress) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return (yield this.chainController.getAccount({ address: blockchainAddress })).nonce;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** @inheritDoc */
|
|
54
|
+
getTransaction(shardId, transactionId) {
|
|
55
|
+
return this.shardController.getTransaction({ shardId, transactionId });
|
|
56
|
+
}
|
|
57
|
+
/** @inheritDoc */
|
|
58
|
+
getLatestProductionTime(shardId) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return (yield this.shardController.getLatestBlock({ shardId })).productionTime;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** @inheritDoc */
|
|
64
|
+
putTransaction(serializedTransaction) {
|
|
65
|
+
return this.chainController.putTransaction({ serializedTransaction });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.ShardAndChainControllerTransactionClient = ShardAndChainControllerTransactionClient;
|
|
69
|
+
//# sourceMappingURL=ShardAndChainControllerTransactionClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShardAndChainControllerTransactionClient.js","sourceRoot":"","sources":["../../../src/main/transactionclient/ShardAndChainControllerTransactionClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;AAWH,oEAAoE;AACpE,MAAa,wCAAwC;IAInD;;;;OAIG;IACH,YAAY,eAAmC,EAAE,eAAmC;QAClF,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED,kBAAkB;IACL,UAAU;;YACrB,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC;QACzD,CAAC;KAAA;IAED,kBAAkB;IACL,QAAQ,CAAC,iBAAoC;;YACxD,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACvF,CAAC;KAAA;IAED,kBAAkB;IACX,cAAc,CAAC,OAAe,EAAE,aAAqB;QAC1D,OAAO,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,kBAAkB;IACL,uBAAuB,CAAC,OAAe;;YAClD,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;QACjF,CAAC;KAAA;IAED,kBAAkB;IACX,cAAc,CAAC,qBAA4C;QAChE,OAAO,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,EAAE,qBAAqB,EAAE,CAAC,CAAC;IACxE,CAAC;CACF;AAtCD,4FAsCC"}
|
|
@@ -20,6 +20,13 @@ export declare class SignedTransaction {
|
|
|
20
20
|
* @returns the signed transaction.
|
|
21
21
|
*/
|
|
22
22
|
static create(senderAuthentication: SenderAuthentication, nonce: number, validToTime: number, gasCost: number, chainId: string, transaction: Transaction): Promise<SignedTransaction>;
|
|
23
|
+
/**
|
|
24
|
+
* Calculate the SHA256 hash for a transaction payload and a chain id.
|
|
25
|
+
* @param transactionPayload a serialized transaction payload
|
|
26
|
+
* @param chainId the id of the chain
|
|
27
|
+
* @returns the hash that is used when signing a transaction.
|
|
28
|
+
*/
|
|
29
|
+
static calculateHash(transactionPayload: Buffer, chainId: string): string;
|
|
23
30
|
/**
|
|
24
31
|
* Serialize the signed transaction into bytes.
|
|
25
32
|
* @returns the serialized bytes.
|
|
@@ -58,14 +58,23 @@ class SignedTransaction {
|
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
59
|
const inner = { nonce, validToTime, gasCost, innerTransaction: transaction };
|
|
60
60
|
const transactionPayload = serializeInnerPart(inner);
|
|
61
|
-
const hash =
|
|
62
|
-
transactionPayload,
|
|
63
|
-
bitmanipulation_ts_1.BigEndianByteOutput.serialize((out) => out.writeString(chainId)),
|
|
64
|
-
]).toString("hex");
|
|
61
|
+
const hash = SignedTransaction.calculateHash(transactionPayload, chainId);
|
|
65
62
|
const signature = yield senderAuthentication.sign(transactionPayload, chainId);
|
|
66
63
|
return new SignedTransaction(inner, signature, hash);
|
|
67
64
|
});
|
|
68
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Calculate the SHA256 hash for a transaction payload and a chain id.
|
|
68
|
+
* @param transactionPayload a serialized transaction payload
|
|
69
|
+
* @param chainId the id of the chain
|
|
70
|
+
* @returns the hash that is used when signing a transaction.
|
|
71
|
+
*/
|
|
72
|
+
static calculateHash(transactionPayload, chainId) {
|
|
73
|
+
return CryptoUtils_1.CryptoUtils.hashBuffers([
|
|
74
|
+
transactionPayload,
|
|
75
|
+
bitmanipulation_ts_1.BigEndianByteOutput.serialize((out) => out.writeString(chainId)),
|
|
76
|
+
]).toString("hex");
|
|
77
|
+
}
|
|
69
78
|
/**
|
|
70
79
|
* Serialize the signed transaction into bytes.
|
|
71
80
|
* @returns the serialized bytes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignedTransaction.js","sourceRoot":"","sources":["../../../src/main/transactionclient/SignedTransaction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;AAEH,kDAAuB;AACvB,0EAAwE;AACxE,gDAA6C;AAG7C;;;;GAIG;AACH,MAAa,iBAAiB;IAK5B,YAAoB,KAAgB,EAAE,SAAoB,EAAE,IAAU;QACpE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAO,MAAM,CACxB,oBAA0C,EAC1C,KAAa,EACb,WAAmB,EACnB,OAAe,EACf,OAAe,EACf,WAAwB;;YAExB,MAAM,KAAK,GAAc,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC;YACxF,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,
|
|
1
|
+
{"version":3,"file":"SignedTransaction.js","sourceRoot":"","sources":["../../../src/main/transactionclient/SignedTransaction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;AAEH,kDAAuB;AACvB,0EAAwE;AACxE,gDAA6C;AAG7C;;;;GAIG;AACH,MAAa,iBAAiB;IAK5B,YAAoB,KAAgB,EAAE,SAAoB,EAAE,IAAU;QACpE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;;;;;;OASG;IACI,MAAM,CAAO,MAAM,CACxB,oBAA0C,EAC1C,KAAa,EACb,WAAmB,EACnB,OAAe,EACf,OAAe,EACf,WAAwB;;YAExB,MAAM,KAAK,GAAc,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC;YACxF,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,iBAAiB,CAAC,aAAa,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;YA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CAAC,gBAAgB,CAAC;IACrC,CAAC;CACF;AApGD,8CAoGC;AAcD,iEAAiE;AACjE,SAAS,kBAAkB,CAAC,SAAoB;IAC9C,OAAO,wCAAmB,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;QAC3C,GAAG,CAAC,QAAQ,CAAC,IAAI,eAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QACtC,GAAG,CAAC,QAAQ,CAAC,IAAI,eAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;QAC5C,GAAG,CAAC,QAAQ,CAAC,IAAI,eAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;QACvE,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpD,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ExecutedTransaction } from "../generated/openapi";
|
|
2
|
+
/** Status for a transaction and the whole tree of spawned events. */
|
|
3
|
+
export declare class TransactionTree {
|
|
4
|
+
/** The original transaction. */
|
|
5
|
+
readonly transaction: ExecutedTransaction;
|
|
6
|
+
/** List of spawned events from the transaction. */
|
|
7
|
+
readonly events: ExecutedTransaction[];
|
|
8
|
+
/**
|
|
9
|
+
* Create new TransactionTree.
|
|
10
|
+
* @param transaction the original transaction.
|
|
11
|
+
* @param events list of spawned events from the transaction.
|
|
12
|
+
*/
|
|
13
|
+
constructor(transaction: ExecutedTransaction, events: ExecutedTransaction[]);
|
|
14
|
+
/**
|
|
15
|
+
* Check if the executed transaction tree includes any transactions or events which did not
|
|
16
|
+
* succeed.
|
|
17
|
+
* @returns true if the transaction tree includes any failures, false if all succeeded.
|
|
18
|
+
*/
|
|
19
|
+
hasFailures(): boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (C) 2022 - 2023 Partisia Blockchain Foundation
|
|
4
|
+
*
|
|
5
|
+
* This program is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.TransactionTree = void 0;
|
|
21
|
+
/** Status for a transaction and the whole tree of spawned events. */
|
|
22
|
+
class TransactionTree {
|
|
23
|
+
/**
|
|
24
|
+
* Create new TransactionTree.
|
|
25
|
+
* @param transaction the original transaction.
|
|
26
|
+
* @param events list of spawned events from the transaction.
|
|
27
|
+
*/
|
|
28
|
+
constructor(transaction, events) {
|
|
29
|
+
this.transaction = transaction;
|
|
30
|
+
this.events = events;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if the executed transaction tree includes any transactions or events which did not
|
|
34
|
+
* succeed.
|
|
35
|
+
* @returns true if the transaction tree includes any failures, false if all succeeded.
|
|
36
|
+
*/
|
|
37
|
+
hasFailures() {
|
|
38
|
+
if (!this.transaction.executionStatus.success) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
for (const event of this.events) {
|
|
42
|
+
if (!event.executionStatus.success) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.TransactionTree = TransactionTree;
|
|
50
|
+
//# sourceMappingURL=TransactionTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionTree.js","sourceRoot":"","sources":["../../../src/main/transactionclient/TransactionTree.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAIH,qEAAqE;AACrE,MAAa,eAAe;IAM1B;;;;OAIG;IACH,YAAY,WAAgC,EAAE,MAA6B;QACzE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,WAAW;QAChB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,eAAgB,CAAC,OAAO,EAAE,CAAC;YAC/C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,KAAK,CAAC,eAAgB,CAAC,OAAO,EAAE,CAAC;gBACpC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAhCD,0CAgCC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SignedTransaction } from "./SignedTransaction";
|
|
2
|
-
import { ExecutedTransaction, TransactionPointer } from "../generated/openapi";
|
|
2
|
+
import { ExecutedTransaction, SerializedTransaction, TransactionPointer } from "../generated/openapi";
|
|
3
3
|
/** Hash as a 32 byte long hex string. */
|
|
4
4
|
export type Hash = string;
|
|
5
5
|
/** BlockchainAddress as 21 byte long hex string. */
|
|
@@ -40,10 +40,39 @@ export interface SentTransaction {
|
|
|
40
40
|
/** A pointer to the signed transaction that was sent. */
|
|
41
41
|
transactionPointer: TransactionPointer;
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
/**
|
|
44
|
+
* A client for getting the information to create a transaction, and send it after creation and
|
|
45
|
+
* signing.
|
|
46
|
+
*/
|
|
47
|
+
export interface BlockchainClientForTransaction {
|
|
48
|
+
/**
|
|
49
|
+
* Get the chain ID for the running chain.
|
|
50
|
+
* @returns the chain ID string.
|
|
51
|
+
*/
|
|
52
|
+
getChainId(): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Get the current nonce to use when signing a transaction for the given account.
|
|
55
|
+
* @param blockchainAddress the address to get the nonce for.
|
|
56
|
+
* @returns the current nonce to use for signing.
|
|
57
|
+
*/
|
|
58
|
+
getNonce(blockchainAddress: BlockchainAddress): Promise<number>;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieve an executed transaction from the blockchain.
|
|
61
|
+
* @param shardId The name of the shard to interact with.
|
|
62
|
+
* @param transactionId The transaction hash.
|
|
63
|
+
* @returns The retrieved transaction.
|
|
64
|
+
*/
|
|
65
|
+
getTransaction(shardId: string, transactionId: Hash): Promise<ExecutedTransaction>;
|
|
66
|
+
/**
|
|
67
|
+
* Get the production time from the latest created block of a specific shard.
|
|
68
|
+
* @param shardId the id of the shard.
|
|
69
|
+
* @returns the production time of the latest created block.
|
|
70
|
+
*/
|
|
71
|
+
getLatestProductionTime(shardId: string): Promise<number>;
|
|
72
|
+
/**
|
|
73
|
+
* Send a signed transaction to the chain and return a pointer to the transaction.
|
|
74
|
+
* @param serializedTransaction the transaction to send.
|
|
75
|
+
* @returns a pointer to the transaction on chain.
|
|
76
|
+
*/
|
|
77
|
+
putTransaction(serializedTransaction: SerializedTransaction): Promise<TransactionPointer>;
|
|
49
78
|
}
|