@algorandfoundation/algokit-utils 10.0.0-alpha.31 → 10.0.0-alpha.32
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/account-manager.d.ts +448 -0
- package/account-manager.js +623 -0
- package/account-manager.js.map +1 -0
- package/account-manager.mjs +620 -0
- package/account-manager.mjs.map +1 -0
- package/account.d.ts +156 -0
- package/account.js +10 -0
- package/account.js.map +1 -0
- package/account.mjs +9 -0
- package/account.mjs.map +1 -0
- package/algorand-client-transaction-creator.d.ts +1103 -0
- package/algorand-client-transaction-creator.js +735 -0
- package/algorand-client-transaction-creator.js.map +1 -0
- package/algorand-client-transaction-creator.mjs +734 -0
- package/algorand-client-transaction-creator.mjs.map +1 -0
- package/algorand-client-transaction-sender.d.ts +1317 -0
- package/algorand-client-transaction-sender.js +933 -0
- package/algorand-client-transaction-sender.js.map +1 -0
- package/algorand-client-transaction-sender.mjs +932 -0
- package/algorand-client-transaction-sender.mjs.map +1 -0
- package/algorand-client.d.ts +246 -0
- package/algorand-client.js +325 -0
- package/algorand-client.js.map +1 -0
- package/algorand-client.mjs +325 -0
- package/algorand-client.mjs.map +1 -0
- package/amount.d.ts +46 -3
- package/amount.js +92 -13
- package/amount.js.map +1 -1
- package/amount.mjs +80 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +2130 -0
- package/app-client.js +909 -0
- package/app-client.js.map +1 -0
- package/app-client.mjs +908 -0
- package/app-client.mjs.map +1 -0
- package/app-deployer.d.ts +166 -0
- package/app-deployer.js +353 -0
- package/app-deployer.js.map +1 -0
- package/app-deployer.mjs +353 -0
- package/app-deployer.mjs.map +1 -0
- package/app-factory.d.ts +965 -0
- package/app-factory.js +448 -0
- package/app-factory.js.map +1 -0
- package/app-factory.mjs +448 -0
- package/app-factory.mjs.map +1 -0
- package/app-manager.d.ts +323 -0
- package/app-manager.js +468 -0
- package/app-manager.js.map +1 -0
- package/app-manager.mjs +468 -0
- package/app-manager.mjs.map +1 -0
- package/app-spec.d.ts +203 -0
- package/app-spec.js +137 -0
- package/app-spec.js.map +1 -0
- package/app-spec.mjs +137 -0
- package/app-spec.mjs.map +1 -0
- package/app.d.ts +257 -0
- package/app.js +49 -0
- package/app.js.map +1 -0
- package/app.mjs +42 -0
- package/app.mjs.map +1 -0
- package/asset-manager.d.ts +212 -0
- package/asset-manager.js +166 -0
- package/asset-manager.js.map +1 -0
- package/asset-manager.mjs +166 -0
- package/asset-manager.mjs.map +1 -0
- package/async-event-emitter.d.ts +16 -0
- package/async-event-emitter.js +38 -0
- package/async-event-emitter.js.map +1 -0
- package/async-event-emitter.mjs +37 -0
- package/async-event-emitter.mjs.map +1 -0
- package/client-manager.d.ts +475 -0
- package/client-manager.js +616 -0
- package/client-manager.js.map +1 -0
- package/client-manager.mjs +616 -0
- package/client-manager.mjs.map +1 -0
- package/composer.d.ts +947 -0
- package/composer.js +1584 -0
- package/composer.js.map +1 -0
- package/composer.mjs +1583 -0
- package/composer.mjs.map +1 -0
- package/config.d.ts +1 -1
- package/config.js +2 -2
- package/config.js.map +1 -1
- package/config.mjs +1 -1
- package/config.mjs.map +1 -1
- package/debugging.d.ts +47 -0
- package/debugging.js +20 -0
- package/debugging.js.map +1 -0
- package/debugging.mjs +15 -0
- package/debugging.mjs.map +1 -0
- package/dispenser-client.d.ts +90 -0
- package/dispenser-client.js +127 -0
- package/dispenser-client.js.map +1 -0
- package/dispenser-client.mjs +127 -0
- package/dispenser-client.mjs.map +1 -0
- package/expand.d.ts +2 -0
- package/expand.js +0 -0
- package/expand.mjs +0 -0
- package/index.d.ts +6 -5
- package/index.js +4 -3
- package/index.mjs +5 -5
- package/indexer-client/indexer-lookup.d.ts +1 -1
- package/indexer-client/indexer-lookup.js.map +1 -1
- package/indexer-client/indexer-lookup.mjs.map +1 -1
- package/indexer.d.ts +40 -0
- package/indexer.js +38 -0
- package/indexer.js.map +1 -0
- package/indexer.mjs +35 -0
- package/indexer.mjs.map +1 -0
- package/instance-of.d.ts +8 -0
- package/kmd-account-manager.d.ts +74 -0
- package/kmd-account-manager.js +167 -0
- package/kmd-account-manager.js.map +1 -0
- package/kmd-account-manager.mjs +165 -0
- package/kmd-account-manager.mjs.map +1 -0
- package/lifecycle-events.d.ts +14 -0
- package/lifecycle-events.js +11 -0
- package/lifecycle-events.js.map +1 -0
- package/lifecycle-events.mjs +10 -0
- package/lifecycle-events.mjs.map +1 -0
- package/logging.d.ts +13 -0
- package/logging.js +47 -0
- package/logging.js.map +1 -0
- package/logging.mjs +42 -0
- package/logging.mjs.map +1 -0
- package/logic-error.d.ts +39 -0
- package/logic-error.js +54 -0
- package/logic-error.js.map +1 -0
- package/logic-error.mjs +53 -0
- package/logic-error.mjs.map +1 -0
- package/network-client.d.ts +43 -0
- package/network-client.js +14 -0
- package/network-client.js.map +1 -0
- package/network-client.mjs +13 -0
- package/network-client.mjs.map +1 -0
- package/package.json +11 -1
- package/testing/account.d.ts +2 -2
- package/testing/account.js +1 -1
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +1 -1
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +2 -2
- package/testing/fixtures/algorand-fixture.js +2 -2
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +2 -2
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/index.d.ts +2 -1
- package/testing/test-logger.d.ts +1 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs.map +1 -1
- package/testing/types.d.ts +156 -0
- package/transaction/index.d.ts +4 -0
- package/transaction/index.js +9 -0
- package/transaction/index.mjs +4 -0
- package/transaction/perform-transaction-composer-simulate.d.ts +1 -1
- package/transaction/perform-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +2 -2
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs.map +1 -1
- package/transaction/types.d.ts +133 -0
- package/transactions/app-call.d.ts +1 -1
- package/transactions/app-call.js +1 -1
- package/transactions/app-call.js.map +1 -1
- package/transactions/app-call.mjs +1 -1
- package/transactions/app-call.mjs.map +1 -1
- package/transactions/common.d.ts +1 -1
- package/transactions/common.js.map +1 -1
- package/transactions/common.mjs.map +1 -1
- package/transactions/method-call.d.ts +1 -1
- package/transactions/method-call.js +1 -1
- package/transactions/method-call.js.map +1 -1
- package/transactions/method-call.mjs +1 -1
- package/transactions/method-call.mjs.map +1 -1
- package/transactions/payment.d.ts +1 -1
- package/transactions/payment.js.map +1 -1
- package/transactions/payment.mjs.map +1 -1
- package/types/account-manager.d.ts +11 -442
- package/types/account-manager.js +5 -616
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +5 -614
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +8 -150
- package/types/account.js +3 -4
- package/types/account.js.map +1 -1
- package/types/account.mjs +4 -4
- package/types/account.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +5 -1098
- package/types/algorand-client-transaction-creator.js +3 -729
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +4 -729
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +5 -1312
- package/types/algorand-client-transaction-sender.js +3 -927
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +3 -926
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +5 -241
- package/types/algorand-client.js +3 -319
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +3 -319
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +6 -45
- package/types/amount.js +3 -79
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +4 -79
- package/types/amount.mjs.map +1 -1
- package/types/app-client.d.ts +75 -2125
- package/types/app-client.js +3 -903
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +3 -902
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +21 -161
- package/types/app-deployer.js +3 -347
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +3 -347
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +21 -960
- package/types/app-factory.js +3 -442
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +3 -442
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +15 -318
- package/types/app-manager.js +3 -462
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +3 -462
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +39 -198
- package/types/app-spec.js +3 -131
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +3 -131
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +62 -247
- package/types/app.js +15 -37
- package/types/app.js.map +1 -1
- package/types/app.mjs +16 -37
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +9 -207
- package/types/asset-manager.js +3 -160
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +3 -160
- package/types/asset-manager.mjs.map +1 -1
- package/types/async-event-emitter.d.ts +7 -11
- package/types/async-event-emitter.js +3 -32
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +4 -32
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +27 -470
- package/types/client-manager.js +3 -610
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +3 -610
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +79 -943
- package/types/composer.js +3 -1578
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +3 -1577
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +7 -52
- package/types/config.js +3 -74
- package/types/config.js.map +1 -1
- package/types/config.mjs +3 -74
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +12 -37
- package/types/debugging.js +11 -10
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -10
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +11 -85
- package/types/dispenser-client.js +3 -121
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +3 -121
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +8 -2
- package/types/indexer.d.ts +16 -36
- package/types/indexer.js +7 -30
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs +8 -30
- package/types/indexer.mjs.map +1 -1
- package/types/instance-of.d.ts +4 -4
- package/types/kmd-account-manager.d.ts +5 -69
- package/types/kmd-account-manager.js +3 -161
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +3 -159
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +7 -9
- package/types/lifecycle-events.js +3 -5
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs +4 -5
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/logging.d.ts +14 -9
- package/types/logging.js +11 -37
- package/types/logging.js.map +1 -1
- package/types/logging.mjs +12 -37
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +8 -35
- package/types/logic-error.js +3 -48
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +4 -48
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +10 -39
- package/types/network-client.js +3 -8
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs +4 -8
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +13 -151
- package/types/transaction.d.ts +33 -128
- package/updatable-config.d.ts +57 -0
- package/updatable-config.js +80 -0
- package/updatable-config.js.map +1 -0
- package/updatable-config.mjs +80 -0
- package/updatable-config.mjs.map +1 -0
- package/util.js +1 -1
- package/util.js.map +1 -1
- package/util.mjs +1 -1
- package/util.mjs.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic-error.js","names":[],"sources":["../src/logic-error.ts"],"sourcesContent":["const LOGIC_ERROR = /transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/\n// inner tx 0 failed: logic eval error: err opcode executed. Details: app=6248, pc=29, opcodes=tx\nconst INNER_LOGIC_ERROR = /inner tx (\\d+) failed:.*?pc=([0-9]+)/\n\n/**\n * Details about a smart contract logic error\n */\nexport interface LogicErrorDetails {\n /** The ID of the transaction with the logic error */\n txId: string\n /** The program counter where the error was */\n pc: number\n /** The error message */\n msg: string\n /** The full error description */\n desc: string\n /** Any trace information included in the error */\n traces: Record<string, unknown>[]\n}\n\n/** Wraps key functionality around processing logic errors */\nexport class LogicError extends Error {\n /** Takes an error message and parses out the details of any logic errors in there.\n * @param error The error message to parse\n * @returns The logic error details if any, or undefined\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static parseLogicError(error: any): LogicErrorDetails | undefined {\n const errorMessage = error.message\n const res = LOGIC_ERROR.exec(errorMessage)\n const innerRes = INNER_LOGIC_ERROR.exec(errorMessage)\n\n if (res === null || res.length <= 3) return undefined\n\n return {\n txId: res[1],\n msg: res[2],\n desc: errorMessage,\n pc: parseInt(innerRes?.[2] ?? res[3] ?? '0'),\n traces: error.traces,\n } as LogicErrorDetails\n }\n\n public led: LogicErrorDetails\n public program: string[]\n public lines = 5\n public teal_line = 0\n override stack?: string\n\n /**\n * Create a new logic error object.\n * @param errorDetails The details of the logic error\n * @param program The TEAL source code, split by line\n * @param getLineForPc The source map of the TEAL source code\n */\n constructor(errorDetails: LogicErrorDetails, program: string[], getLineForPc: (pc: number) => number | undefined) {\n super()\n this.led = errorDetails\n this.program = program\n\n const line = getLineForPc(errorDetails.pc)\n this.teal_line = line === undefined ? 0 : line\n\n this.message = `${this.led.msg}. at:${line}. ${this.led.desc}`\n\n if (this.teal_line > 0) {\n const start = this.teal_line > this.lines ? this.teal_line - this.lines : 0\n const stop = program.length > this.teal_line + this.lines ? this.teal_line + this.lines : program.length\n\n const stack_lines = program.slice(start, stop)\n\n stack_lines[stack_lines.length / 2] += ' <--- Error'\n\n this.stack = stack_lines.join('\\n')\n }\n }\n}\n"],"mappings":";;AAAA,MAAM,cAAc;AAEpB,MAAM,oBAAoB;;AAmB1B,IAAa,aAAb,cAAgC,MAAM;;;;;CAMpC,OAAO,gBAAgB,OAA2C;EAChE,MAAM,eAAe,MAAM;EAC3B,MAAM,MAAM,YAAY,KAAK,aAAa;EAC1C,MAAM,WAAW,kBAAkB,KAAK,aAAa;AAErD,MAAI,QAAQ,QAAQ,IAAI,UAAU,EAAG,QAAO;AAE5C,SAAO;GACL,MAAM,IAAI;GACV,KAAK,IAAI;GACT,MAAM;GACN,IAAI,SAAS,WAAW,MAAM,IAAI,MAAM,IAAI;GAC5C,QAAQ,MAAM;GACf;;CAGH,AAAO;CACP,AAAO;CACP,AAAO,QAAQ;CACf,AAAO,YAAY;CACnB,AAAS;;;;;;;CAQT,YAAY,cAAiC,SAAmB,cAAkD;AAChH,SAAO;AACP,OAAK,MAAM;AACX,OAAK,UAAU;EAEf,MAAM,OAAO,aAAa,aAAa,GAAG;AAC1C,OAAK,YAAY,SAAS,SAAY,IAAI;AAE1C,OAAK,UAAU,GAAG,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI;AAExD,MAAI,KAAK,YAAY,GAAG;GACtB,MAAM,QAAQ,KAAK,YAAY,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ;GAC1E,MAAM,OAAO,QAAQ,SAAS,KAAK,YAAY,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ,QAAQ;GAElG,MAAM,cAAc,QAAQ,MAAM,OAAO,KAAK;AAE9C,eAAY,YAAY,SAAS,MAAM;AAEvC,QAAK,QAAQ,YAAY,KAAK,KAAK"}
|
package/logic-error.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/logic-error.ts
|
|
2
|
+
const LOGIC_ERROR = /transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/;
|
|
3
|
+
const INNER_LOGIC_ERROR = /inner tx (\d+) failed:.*?pc=([0-9]+)/;
|
|
4
|
+
/** Wraps key functionality around processing logic errors */
|
|
5
|
+
var LogicError = class extends Error {
|
|
6
|
+
/** Takes an error message and parses out the details of any logic errors in there.
|
|
7
|
+
* @param error The error message to parse
|
|
8
|
+
* @returns The logic error details if any, or undefined
|
|
9
|
+
*/
|
|
10
|
+
static parseLogicError(error) {
|
|
11
|
+
const errorMessage = error.message;
|
|
12
|
+
const res = LOGIC_ERROR.exec(errorMessage);
|
|
13
|
+
const innerRes = INNER_LOGIC_ERROR.exec(errorMessage);
|
|
14
|
+
if (res === null || res.length <= 3) return void 0;
|
|
15
|
+
return {
|
|
16
|
+
txId: res[1],
|
|
17
|
+
msg: res[2],
|
|
18
|
+
desc: errorMessage,
|
|
19
|
+
pc: parseInt(innerRes?.[2] ?? res[3] ?? "0"),
|
|
20
|
+
traces: error.traces
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
led;
|
|
24
|
+
program;
|
|
25
|
+
lines = 5;
|
|
26
|
+
teal_line = 0;
|
|
27
|
+
stack;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new logic error object.
|
|
30
|
+
* @param errorDetails The details of the logic error
|
|
31
|
+
* @param program The TEAL source code, split by line
|
|
32
|
+
* @param getLineForPc The source map of the TEAL source code
|
|
33
|
+
*/
|
|
34
|
+
constructor(errorDetails, program, getLineForPc) {
|
|
35
|
+
super();
|
|
36
|
+
this.led = errorDetails;
|
|
37
|
+
this.program = program;
|
|
38
|
+
const line = getLineForPc(errorDetails.pc);
|
|
39
|
+
this.teal_line = line === void 0 ? 0 : line;
|
|
40
|
+
this.message = `${this.led.msg}. at:${line}. ${this.led.desc}`;
|
|
41
|
+
if (this.teal_line > 0) {
|
|
42
|
+
const start = this.teal_line > this.lines ? this.teal_line - this.lines : 0;
|
|
43
|
+
const stop = program.length > this.teal_line + this.lines ? this.teal_line + this.lines : program.length;
|
|
44
|
+
const stack_lines = program.slice(start, stop);
|
|
45
|
+
stack_lines[stack_lines.length / 2] += " <--- Error";
|
|
46
|
+
this.stack = stack_lines.join("\n");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { LogicError };
|
|
53
|
+
//# sourceMappingURL=logic-error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic-error.mjs","names":[],"sources":["../src/logic-error.ts"],"sourcesContent":["const LOGIC_ERROR = /transaction ([A-Z0-9]+): logic eval error: (.*). Details: .*pc=([0-9]+).*/\n// inner tx 0 failed: logic eval error: err opcode executed. Details: app=6248, pc=29, opcodes=tx\nconst INNER_LOGIC_ERROR = /inner tx (\\d+) failed:.*?pc=([0-9]+)/\n\n/**\n * Details about a smart contract logic error\n */\nexport interface LogicErrorDetails {\n /** The ID of the transaction with the logic error */\n txId: string\n /** The program counter where the error was */\n pc: number\n /** The error message */\n msg: string\n /** The full error description */\n desc: string\n /** Any trace information included in the error */\n traces: Record<string, unknown>[]\n}\n\n/** Wraps key functionality around processing logic errors */\nexport class LogicError extends Error {\n /** Takes an error message and parses out the details of any logic errors in there.\n * @param error The error message to parse\n * @returns The logic error details if any, or undefined\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static parseLogicError(error: any): LogicErrorDetails | undefined {\n const errorMessage = error.message\n const res = LOGIC_ERROR.exec(errorMessage)\n const innerRes = INNER_LOGIC_ERROR.exec(errorMessage)\n\n if (res === null || res.length <= 3) return undefined\n\n return {\n txId: res[1],\n msg: res[2],\n desc: errorMessage,\n pc: parseInt(innerRes?.[2] ?? res[3] ?? '0'),\n traces: error.traces,\n } as LogicErrorDetails\n }\n\n public led: LogicErrorDetails\n public program: string[]\n public lines = 5\n public teal_line = 0\n override stack?: string\n\n /**\n * Create a new logic error object.\n * @param errorDetails The details of the logic error\n * @param program The TEAL source code, split by line\n * @param getLineForPc The source map of the TEAL source code\n */\n constructor(errorDetails: LogicErrorDetails, program: string[], getLineForPc: (pc: number) => number | undefined) {\n super()\n this.led = errorDetails\n this.program = program\n\n const line = getLineForPc(errorDetails.pc)\n this.teal_line = line === undefined ? 0 : line\n\n this.message = `${this.led.msg}. at:${line}. ${this.led.desc}`\n\n if (this.teal_line > 0) {\n const start = this.teal_line > this.lines ? this.teal_line - this.lines : 0\n const stop = program.length > this.teal_line + this.lines ? this.teal_line + this.lines : program.length\n\n const stack_lines = program.slice(start, stop)\n\n stack_lines[stack_lines.length / 2] += ' <--- Error'\n\n this.stack = stack_lines.join('\\n')\n }\n }\n}\n"],"mappings":";AAAA,MAAM,cAAc;AAEpB,MAAM,oBAAoB;;AAmB1B,IAAa,aAAb,cAAgC,MAAM;;;;;CAMpC,OAAO,gBAAgB,OAA2C;EAChE,MAAM,eAAe,MAAM;EAC3B,MAAM,MAAM,YAAY,KAAK,aAAa;EAC1C,MAAM,WAAW,kBAAkB,KAAK,aAAa;AAErD,MAAI,QAAQ,QAAQ,IAAI,UAAU,EAAG,QAAO;AAE5C,SAAO;GACL,MAAM,IAAI;GACV,KAAK,IAAI;GACT,MAAM;GACN,IAAI,SAAS,WAAW,MAAM,IAAI,MAAM,IAAI;GAC5C,QAAQ,MAAM;GACf;;CAGH,AAAO;CACP,AAAO;CACP,AAAO,QAAQ;CACf,AAAO,YAAY;CACnB,AAAS;;;;;;;CAQT,YAAY,cAAiC,SAAmB,cAAkD;AAChH,SAAO;AACP,OAAK,MAAM;AACX,OAAK,UAAU;EAEf,MAAM,OAAO,aAAa,aAAa,GAAG;AAC1C,OAAK,YAAY,SAAS,SAAY,IAAI;AAE1C,OAAK,UAAU,GAAG,KAAK,IAAI,IAAI,OAAO,KAAK,IAAI,KAAK,IAAI;AAExD,MAAI,KAAK,YAAY,GAAG;GACtB,MAAM,QAAQ,KAAK,YAAY,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ;GAC1E,MAAM,OAAO,QAAQ,SAAS,KAAK,YAAY,KAAK,QAAQ,KAAK,YAAY,KAAK,QAAQ,QAAQ;GAElG,MAAM,cAAc,QAAQ,MAAM,OAAO,KAAK;AAE9C,eAAY,YAAY,SAAS,MAAM;AAEvC,QAAK,QAAQ,YAAY,KAAK,KAAK"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/network-client.d.ts
|
|
2
|
+
/** Config for an Algorand SDK client. */
|
|
3
|
+
interface AlgoClientConfig {
|
|
4
|
+
/** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */
|
|
5
|
+
server: string;
|
|
6
|
+
/** The port to use e.g. 4001, 443, etc. */
|
|
7
|
+
port?: string | number;
|
|
8
|
+
/** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */
|
|
9
|
+
token?: string | {
|
|
10
|
+
[name: string]: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Configuration for algod, indexer and kmd clients. */
|
|
14
|
+
interface AlgoConfig {
|
|
15
|
+
/** Algod client configuration */
|
|
16
|
+
algodConfig: AlgoClientConfig;
|
|
17
|
+
/** Indexer client configuration */
|
|
18
|
+
indexerConfig?: AlgoClientConfig;
|
|
19
|
+
/** Kmd configuration */
|
|
20
|
+
kmdConfig?: AlgoClientConfig;
|
|
21
|
+
}
|
|
22
|
+
/** Details of the current network. */
|
|
23
|
+
interface NetworkDetails {
|
|
24
|
+
/** Whether or not the network is TestNet. */
|
|
25
|
+
isTestNet: boolean;
|
|
26
|
+
/** Whether or not the network is MainNet. */
|
|
27
|
+
isMainNet: boolean;
|
|
28
|
+
/** Whether or not the network is LocalNet. */
|
|
29
|
+
isLocalNet: boolean;
|
|
30
|
+
/** The genesis ID of the current network. */
|
|
31
|
+
genesisId: string;
|
|
32
|
+
/** The base64 genesis hash of the current network. */
|
|
33
|
+
genesisHash: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if the given network genesisId is associated with a LocalNet network.
|
|
37
|
+
* @param genesisId The network genesis ID
|
|
38
|
+
* @returns Whether the given genesis ID is associated with a LocalNet network
|
|
39
|
+
*/
|
|
40
|
+
declare function genesisIdIsLocalNet(genesisId: string): boolean;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { AlgoClientConfig, AlgoConfig, NetworkDetails, genesisIdIsLocalNet };
|
|
43
|
+
//# sourceMappingURL=network-client.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/network-client.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns true if the given network genesisId is associated with a LocalNet network.
|
|
5
|
+
* @param genesisId The network genesis ID
|
|
6
|
+
* @returns Whether the given genesis ID is associated with a LocalNet network
|
|
7
|
+
*/
|
|
8
|
+
function genesisIdIsLocalNet(genesisId) {
|
|
9
|
+
return genesisId === "devnet-v1" || genesisId === "sandnet-v1" || genesisId === "dockernet-v1";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.genesisIdIsLocalNet = genesisIdIsLocalNet;
|
|
14
|
+
//# sourceMappingURL=network-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-client.js","names":[],"sources":["../src/network-client.ts"],"sourcesContent":["/** Config for an Algorand SDK client. */\nexport interface AlgoClientConfig {\n /** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */\n server: string\n /** The port to use e.g. 4001, 443, etc. */\n port?: string | number\n /** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */\n token?: string | { [name: string]: string }\n}\n\n/** Configuration for algod, indexer and kmd clients. */\nexport interface AlgoConfig {\n /** Algod client configuration */\n algodConfig: AlgoClientConfig\n /** Indexer client configuration */\n indexerConfig?: AlgoClientConfig\n /** Kmd configuration */\n kmdConfig?: AlgoClientConfig\n}\n\n/** Details of the current network. */\nexport interface NetworkDetails {\n /** Whether or not the network is TestNet. */\n isTestNet: boolean\n /** Whether or not the network is MainNet. */\n isMainNet: boolean\n /** Whether or not the network is LocalNet. */\n isLocalNet: boolean\n /** The genesis ID of the current network. */\n genesisId: string\n /** The base64 genesis hash of the current network. */\n genesisHash: string\n}\n\n/**\n * Returns true if the given network genesisId is associated with a LocalNet network.\n * @param genesisId The network genesis ID\n * @returns Whether the given genesis ID is associated with a LocalNet network\n */\nexport function genesisIdIsLocalNet(genesisId: string) {\n return genesisId === 'devnet-v1' || genesisId === 'sandnet-v1' || genesisId === 'dockernet-v1'\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,oBAAoB,WAAmB;AACrD,QAAO,cAAc,eAAe,cAAc,gBAAgB,cAAc"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/network-client.ts
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the given network genesisId is associated with a LocalNet network.
|
|
4
|
+
* @param genesisId The network genesis ID
|
|
5
|
+
* @returns Whether the given genesis ID is associated with a LocalNet network
|
|
6
|
+
*/
|
|
7
|
+
function genesisIdIsLocalNet(genesisId) {
|
|
8
|
+
return genesisId === "devnet-v1" || genesisId === "sandnet-v1" || genesisId === "dockernet-v1";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { genesisIdIsLocalNet };
|
|
13
|
+
//# sourceMappingURL=network-client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-client.mjs","names":[],"sources":["../src/network-client.ts"],"sourcesContent":["/** Config for an Algorand SDK client. */\nexport interface AlgoClientConfig {\n /** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */\n server: string\n /** The port to use e.g. 4001, 443, etc. */\n port?: string | number\n /** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */\n token?: string | { [name: string]: string }\n}\n\n/** Configuration for algod, indexer and kmd clients. */\nexport interface AlgoConfig {\n /** Algod client configuration */\n algodConfig: AlgoClientConfig\n /** Indexer client configuration */\n indexerConfig?: AlgoClientConfig\n /** Kmd configuration */\n kmdConfig?: AlgoClientConfig\n}\n\n/** Details of the current network. */\nexport interface NetworkDetails {\n /** Whether or not the network is TestNet. */\n isTestNet: boolean\n /** Whether or not the network is MainNet. */\n isMainNet: boolean\n /** Whether or not the network is LocalNet. */\n isLocalNet: boolean\n /** The genesis ID of the current network. */\n genesisId: string\n /** The base64 genesis hash of the current network. */\n genesisHash: string\n}\n\n/**\n * Returns true if the given network genesisId is associated with a LocalNet network.\n * @param genesisId The network genesis ID\n * @returns Whether the given genesis ID is associated with a LocalNet network\n */\nexport function genesisIdIsLocalNet(genesisId: string) {\n return genesisId === 'devnet-v1' || genesisId === 'sandnet-v1' || genesisId === 'dockernet-v1'\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,oBAAoB,WAAmB;AACrD,QAAO,cAAc,eAAe,cAAc,gBAAgB,cAAc"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"**"
|
|
7
7
|
],
|
|
8
8
|
"name": "@algorandfoundation/algokit-utils",
|
|
9
|
-
"version": "10.0.0-alpha.
|
|
9
|
+
"version": "10.0.0-alpha.32",
|
|
10
10
|
"private": false,
|
|
11
11
|
"description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
|
|
12
12
|
"author": "Algorand Foundation",
|
|
@@ -46,6 +46,11 @@
|
|
|
46
46
|
"import": "./transact/index.mjs",
|
|
47
47
|
"require": "./transact/index.js"
|
|
48
48
|
},
|
|
49
|
+
"./transaction": {
|
|
50
|
+
"types": "./transaction/index.d.ts",
|
|
51
|
+
"import": "./transaction/index.mjs",
|
|
52
|
+
"require": "./transaction/index.js"
|
|
53
|
+
},
|
|
49
54
|
"./algod-client": {
|
|
50
55
|
"types": "./algod-client/index.d.ts",
|
|
51
56
|
"import": "./algod-client/index.mjs",
|
|
@@ -66,6 +71,11 @@
|
|
|
66
71
|
"import": "./algo25/index.mjs",
|
|
67
72
|
"require": "./algo25/index.js"
|
|
68
73
|
},
|
|
74
|
+
"./*": {
|
|
75
|
+
"types": "./*.d.ts",
|
|
76
|
+
"import": "./*.mjs",
|
|
77
|
+
"require": "./*.js"
|
|
78
|
+
},
|
|
69
79
|
"./index.d.ts": "./index.d.ts",
|
|
70
80
|
"./package.json": "./package.json"
|
|
71
81
|
},
|
package/testing/account.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { Address } from "../packages/common/src/address.js";
|
|
|
2
2
|
import { AddressWithSigners, AddressWithTransactionSigner } from "../packages/transact/src/signer.js";
|
|
3
3
|
import { AlgodClient } from "../packages/algod_client/src/client.js";
|
|
4
4
|
import { KmdClient } from "../packages/kmd_client/src/client.js";
|
|
5
|
-
import { AlgorandClient } from "../
|
|
6
|
-
import { GetTestAccountParams } from "
|
|
5
|
+
import { AlgorandClient } from "../algorand-client.js";
|
|
6
|
+
import { GetTestAccountParams } from "./types.js";
|
|
7
7
|
|
|
8
8
|
//#region src/testing/account.d.ts
|
|
9
9
|
|
package/testing/account.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_address = require('../packages/common/src/address.js');
|
|
2
2
|
const require_config = require('../config.js');
|
|
3
|
-
const require_algorand_client = require('../
|
|
3
|
+
const require_algorand_client = require('../algorand-client.js');
|
|
4
4
|
|
|
5
5
|
//#region src/testing/account.ts
|
|
6
6
|
async function getTestAccount({ suppressLog, initialFunds, accountGetter }, algodOrAlgorandClient, kmd) {
|
package/testing/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","names":["AlgorandClient","Address"],"sources":["../../src/testing/account.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { KmdClient } from '@algorandfoundation/algokit-kmd-client'\nimport { AddressWithSigners, AddressWithTransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { AlgorandClient, Config } from '../'\nimport { GetTestAccountParams } from '
|
|
1
|
+
{"version":3,"file":"account.js","names":["AlgorandClient","Address"],"sources":["../../src/testing/account.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { KmdClient } from '@algorandfoundation/algokit-kmd-client'\nimport { AddressWithSigners, AddressWithTransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { AlgorandClient, Config } from '../'\nimport { GetTestAccountParams } from './types'\n\n/**\n * @deprecated Use `getTestAccount(params, algorandClient)` instead. The `algorandClient` object can be created using `AlgorandClient.fromClients({ algod, kmd })`.\n *\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algod An algod client\n * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables and if not found fallback to the default LocalNet KMD client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(\n params: GetTestAccountParams,\n algod: AlgodClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner>\n/**\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algorand An AlgorandClient client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(params: GetTestAccountParams, algorand: AlgorandClient): Promise<Address & AddressWithSigners>\nexport async function getTestAccount(\n { suppressLog, initialFunds, accountGetter }: GetTestAccountParams,\n algodOrAlgorandClient: AlgodClient | AlgorandClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithSigners> {\n const algorand =\n algodOrAlgorandClient instanceof AlgorandClient\n ? algodOrAlgorandClient\n : AlgorandClient.fromClients({\n algod: algodOrAlgorandClient,\n kmd,\n })\n\n const account = accountGetter ? await accountGetter(algorand) : algorand.account.random()\n\n Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}'.`)\n\n const dispenser = await algorand.account.dispenserFromEnvironment()\n\n await algorand.send.payment({\n sender: dispenser,\n receiver: account.addr,\n amount: initialFunds,\n note: 'Funding test account',\n suppressLog,\n })\n\n const accountInfo = await algorand.account.getInformation(account.addr)\n\n Config.getLogger(suppressLog).info('Test account funded; account balance: %d µALGO', accountInfo.balance.microAlgo)\n\n algorand.setSignerFromAccount(account)\n\n const address = Address.fromString(account.addr.toString()) as Address & AddressWithSigners\n for (const key of Object.keys(account as AddressWithSigners)) {\n if (!(key in address)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(address as any)[key] = (account as any)[key]\n }\n }\n\n return address\n}\n"],"mappings":";;;;;AAkCA,eAAsB,eACpB,EAAE,aAAa,cAAc,iBAC7B,uBACA,KACuC;CACvC,MAAM,WACJ,iCAAiCA,yCAC7B,wBACAA,uCAAe,YAAY;EACzB,OAAO;EACP;EACD,CAAC;CAER,MAAM,UAAU,gBAAgB,MAAM,cAAc,SAAS,GAAG,SAAS,QAAQ,QAAQ;AAEzF,uBAAO,UAAU,YAAY,CAAC,KAAK,0CAA0C,QAAQ,KAAK,IAAI;CAE9F,MAAM,YAAY,MAAM,SAAS,QAAQ,0BAA0B;AAEnE,OAAM,SAAS,KAAK,QAAQ;EAC1B,QAAQ;EACR,UAAU,QAAQ;EAClB,QAAQ;EACR,MAAM;EACN;EACD,CAAC;CAEF,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe,QAAQ,KAAK;AAEvE,uBAAO,UAAU,YAAY,CAAC,KAAK,kDAAkD,YAAY,QAAQ,UAAU;AAEnH,UAAS,qBAAqB,QAAQ;CAEtC,MAAM,UAAUC,wBAAQ,WAAW,QAAQ,KAAK,UAAU,CAAC;AAC3D,MAAK,MAAM,OAAO,OAAO,KAAK,QAA8B,CAC1D,KAAI,EAAE,OAAO,SAEV,CAAC,QAAgB,OAAQ,QAAgB;AAI9C,QAAO"}
|
package/testing/account.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Address } from "../packages/common/src/address.mjs";
|
|
2
2
|
import { Config } from "../config.mjs";
|
|
3
|
-
import { AlgorandClient } from "../
|
|
3
|
+
import { AlgorandClient } from "../algorand-client.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/testing/account.ts
|
|
6
6
|
async function getTestAccount({ suppressLog, initialFunds, accountGetter }, algodOrAlgorandClient, kmd) {
|
package/testing/account.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.mjs","names":[],"sources":["../../src/testing/account.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { KmdClient } from '@algorandfoundation/algokit-kmd-client'\nimport { AddressWithSigners, AddressWithTransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { AlgorandClient, Config } from '../'\nimport { GetTestAccountParams } from '
|
|
1
|
+
{"version":3,"file":"account.mjs","names":[],"sources":["../../src/testing/account.ts"],"sourcesContent":["import { AlgodClient } from '@algorandfoundation/algokit-algod-client'\nimport { Address } from '@algorandfoundation/algokit-common'\nimport { KmdClient } from '@algorandfoundation/algokit-kmd-client'\nimport { AddressWithSigners, AddressWithTransactionSigner } from '@algorandfoundation/algokit-transact'\nimport { AlgorandClient, Config } from '../'\nimport { GetTestAccountParams } from './types'\n\n/**\n * @deprecated Use `getTestAccount(params, algorandClient)` instead. The `algorandClient` object can be created using `AlgorandClient.fromClients({ algod, kmd })`.\n *\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algod An algod client\n * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables and if not found fallback to the default LocalNet KMD client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(\n params: GetTestAccountParams,\n algod: AlgodClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithTransactionSigner>\n/**\n * Creates an ephemeral Algorand account for the purposes of testing.\n * Returns a newly created random test account that is funded from the dispenser\n * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!\n * Note: By default this will log the mnemonic of the account.\n * @param params The config for the test account to generate\n * @param algorand An AlgorandClient client\n * @returns The account, with private key loaded\n */\nexport async function getTestAccount(params: GetTestAccountParams, algorand: AlgorandClient): Promise<Address & AddressWithSigners>\nexport async function getTestAccount(\n { suppressLog, initialFunds, accountGetter }: GetTestAccountParams,\n algodOrAlgorandClient: AlgodClient | AlgorandClient,\n kmd?: KmdClient,\n): Promise<Address & AddressWithSigners> {\n const algorand =\n algodOrAlgorandClient instanceof AlgorandClient\n ? algodOrAlgorandClient\n : AlgorandClient.fromClients({\n algod: algodOrAlgorandClient,\n kmd,\n })\n\n const account = accountGetter ? await accountGetter(algorand) : algorand.account.random()\n\n Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}'.`)\n\n const dispenser = await algorand.account.dispenserFromEnvironment()\n\n await algorand.send.payment({\n sender: dispenser,\n receiver: account.addr,\n amount: initialFunds,\n note: 'Funding test account',\n suppressLog,\n })\n\n const accountInfo = await algorand.account.getInformation(account.addr)\n\n Config.getLogger(suppressLog).info('Test account funded; account balance: %d µALGO', accountInfo.balance.microAlgo)\n\n algorand.setSignerFromAccount(account)\n\n const address = Address.fromString(account.addr.toString()) as Address & AddressWithSigners\n for (const key of Object.keys(account as AddressWithSigners)) {\n if (!(key in address)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(address as any)[key] = (account as any)[key]\n }\n }\n\n return address\n}\n"],"mappings":";;;;;AAkCA,eAAsB,eACpB,EAAE,aAAa,cAAc,iBAC7B,uBACA,KACuC;CACvC,MAAM,WACJ,iCAAiC,iBAC7B,wBACA,eAAe,YAAY;EACzB,OAAO;EACP;EACD,CAAC;CAER,MAAM,UAAU,gBAAgB,MAAM,cAAc,SAAS,GAAG,SAAS,QAAQ,QAAQ;AAEzF,QAAO,UAAU,YAAY,CAAC,KAAK,0CAA0C,QAAQ,KAAK,IAAI;CAE9F,MAAM,YAAY,MAAM,SAAS,QAAQ,0BAA0B;AAEnE,OAAM,SAAS,KAAK,QAAQ;EAC1B,QAAQ;EACR,UAAU,QAAQ;EAClB,QAAQ;EACR,MAAM;EACN;EACD,CAAC;CAEF,MAAM,cAAc,MAAM,SAAS,QAAQ,eAAe,QAAQ,KAAK;AAEvE,QAAO,UAAU,YAAY,CAAC,KAAK,kDAAkD,YAAY,QAAQ,UAAU;AAEnH,UAAS,qBAAqB,QAAQ;CAEtC,MAAM,UAAU,QAAQ,WAAW,QAAQ,KAAK,UAAU,CAAC;AAC3D,MAAK,MAAM,OAAO,OAAO,KAAK,QAA8B,CAC1D,KAAI,EAAE,OAAO,SAEV,CAAC,QAAgB,OAAQ,QAAgB;AAI9C,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algokit-log-capture-fixture.js","names":["algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture","Config","hybridLogger: TestLogger","TestLogger"],"sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"sourcesContent":["import { Config } from '../../'\nimport {
|
|
1
|
+
{"version":3,"file":"algokit-log-capture-fixture.js","names":["algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture","Config","hybridLogger: TestLogger","TestLogger"],"sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"sourcesContent":["import { Config } from '../../'\nimport { TestLogger } from '../test-logger'\nimport { AlgoKitLogCaptureFixture } from '../types'\n\n/**\n * Creates a test fixture for capturing AlgoKit logs.\n *\n * @example\n * ```typescript\n * const logs = algoKitLogCaptureFixture()\n *\n * beforeEach(logs.beforeEach)\n * afterEach(logs.afterEach)\n *\n * test('My test', () => {\n * const capturedLogs = logs.testLogger.capturedLogs\n * })\n * ```\n *\n * @returns The fixture\n */\nexport const algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture = () => {\n const originalLogger = Config.logger\n\n let hybridLogger: TestLogger\n\n return {\n get testLogger() {\n return hybridLogger\n },\n beforeEach: () => {\n hybridLogger = new TestLogger(originalLogger)\n Config.configure({\n logger: hybridLogger,\n })\n },\n afterEach: () => {\n Config.configure({\n logger: originalLogger,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAaA,iCAAiE;CAC5E,MAAM,iBAAiBC,sBAAO;CAE9B,IAAIC;AAEJ,QAAO;EACL,IAAI,aAAa;AACf,UAAO;;EAET,kBAAkB;AAChB,kBAAe,IAAIC,+BAAW,eAAe;AAC7C,yBAAO,UAAU,EACf,QAAQ,cACT,CAAC;;EAEJ,iBAAiB;AACf,yBAAO,UAAU,EACf,QAAQ,gBACT,CAAC;;EAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algokit-log-capture-fixture.mjs","names":["algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture","hybridLogger: TestLogger"],"sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"sourcesContent":["import { Config } from '../../'\nimport {
|
|
1
|
+
{"version":3,"file":"algokit-log-capture-fixture.mjs","names":["algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture","hybridLogger: TestLogger"],"sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"sourcesContent":["import { Config } from '../../'\nimport { TestLogger } from '../test-logger'\nimport { AlgoKitLogCaptureFixture } from '../types'\n\n/**\n * Creates a test fixture for capturing AlgoKit logs.\n *\n * @example\n * ```typescript\n * const logs = algoKitLogCaptureFixture()\n *\n * beforeEach(logs.beforeEach)\n * afterEach(logs.afterEach)\n *\n * test('My test', () => {\n * const capturedLogs = logs.testLogger.capturedLogs\n * })\n * ```\n *\n * @returns The fixture\n */\nexport const algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture = () => {\n const originalLogger = Config.logger\n\n let hybridLogger: TestLogger\n\n return {\n get testLogger() {\n return hybridLogger\n },\n beforeEach: () => {\n hybridLogger = new TestLogger(originalLogger)\n Config.configure({\n logger: hybridLogger,\n })\n },\n afterEach: () => {\n Config.configure({\n logger: originalLogger,\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAaA,iCAAiE;CAC5E,MAAM,iBAAiB,OAAO;CAE9B,IAAIC;AAEJ,QAAO;EACL,IAAI,aAAa;AACf,UAAO;;EAET,kBAAkB;AAChB,kBAAe,IAAI,WAAW,eAAe;AAC7C,UAAO,UAAU,EACf,QAAQ,cACT,CAAC;;EAEJ,iBAAiB;AACf,UAAO,UAAU,EACf,QAAQ,gBACT,CAAC;;EAEL"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AlgoConfig } from "../../
|
|
2
|
-
import { AlgorandFixture, AlgorandFixtureConfig } from "
|
|
1
|
+
import { AlgoConfig } from "../../network-client.js";
|
|
2
|
+
import { AlgorandFixture, AlgorandFixtureConfig } from "../types.js";
|
|
3
3
|
|
|
4
4
|
//#region src/testing/fixtures/algorand-fixture.d.ts
|
|
5
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_amount = require('../../amount.js');
|
|
2
2
|
const require_config = require('../../config.js');
|
|
3
|
-
const require_client_manager = require('../../
|
|
4
|
-
const require_algorand_client = require('../../
|
|
3
|
+
const require_client_manager = require('../../client-manager.js');
|
|
4
|
+
const require_algorand_client = require('../../algorand-client.js');
|
|
5
5
|
const require_account = require('../account.js');
|
|
6
6
|
const require_indexer = require('../indexer.js');
|
|
7
7
|
const require_transaction_logger = require('../transaction-logger.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algorand-fixture.js","names":["ClientManager","context: AlgorandTestAutomationContext","algorand: AlgorandClient","TransactionLogger","AlgorandClient","getTestAccount","algos","runWhenIndexerCaughtUp"],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../
|
|
1
|
+
{"version":3,"file":"algorand-fixture.js","names":["ClientManager","context: AlgorandTestAutomationContext","algorand: AlgorandClient","TransactionLogger","AlgorandClient","getTestAccount","algos","runWhenIndexerCaughtUp"],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../algorand-client'\nimport { ClientManager } from '../../client-manager'\nimport { AlgoConfig } from '../../network-client'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../types'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new AlgodClient({ baseUrl: 'http://localhost:12345', headers: { 'X-Algo-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } }),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionById(transactionId)),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"mappings":";;;;;;;;;AA4EA,SAAgB,gBAAgB,eAAuC,QAAsC;AAC3G,iBAAgB;EAAE,GAAG;EAAe,GAAG;EAAQ;AAC/C,KAAI,CAAC,cAAc,SAAS,CAAC,cAAc,WAAW,CAAC,cAAc,IACnE,iBAAgB;EAAE,GAAGA,qCAAc,oCAAoC;EAAE,GAAG;EAAe;CAG7F,MAAM,QAAQ,cAAc,SAASA,qCAAc,eAAe,cAAc,YAAa;CAC7F,MAAM,UAAU,cAAc,WAAWA,qCAAc,iBAAiB,cAAc,cAAe;CACrG,MAAM,MAAM,cAAc,OAAOA,qCAAc,aAAa,cAAc,UAAW;CACrF,IAAIC;CACJ,IAAIC;CAEJ,MAAM,WAAW,YAAY;AAC3B,wBAAO,UAAU,EAAE,OAAO,MAAM,CAAC;EACjC,MAAM,oBAAoB,IAAIC,8CAAmB;EACjD,MAAM,yBAAyB,kBAAkB,QAAQ,MAAM;AAE/D,aAAWC,uCAAe,YAAY;GAAE,OAAO;GAAwB;GAAS;GAAK,CAAC,CAAC,+BAA+B,EAAE;EAExH,MAAM,cAAc,MAAMC,+BAAe;GAAE,cAAc,eAAe,sBAAsBC,qBAAM,GAAG;GAAE,aAAa;GAAM,EAAE,SAAS;AACvI,WAAS,qBAAqB,YAAY;AAI1C,MAAI,MAAM,SAAS,OAAO,YAAY,CACpC,UAAS,yBAAyB,IAAK;AAEzC,YAAU;GACR;GACA,OAAO;GACE;GACJ;GACL;GACA,iBAAiB,OAAO,WAAiC;IACvD,MAAM,UAAU,MAAMD,+BAAe,QAAQ,SAAS;AACtD,aAAS,qBAAqB,QAAQ;AACtC,WAAO;;GAEU;GACnB,sBAAsB,kBAAkB,eAAe,QAAQ;GAC/D,4BAA4B,kBAA0BE,6CAA6B,QAAQ,sBAAsB,cAAc,CAAC;GACjI;;AAGH,QAAO;EACL,IAAI,UAAU;AACZ,OAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0FAA0F;AACxH,UAAO;;EAET,IAAI,WAAW;AACb,UAAO;;EAET,YAAY;EACZ;EACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { algos } from "../../amount.mjs";
|
|
2
2
|
import { Config } from "../../config.mjs";
|
|
3
|
-
import { ClientManager } from "../../
|
|
4
|
-
import { AlgorandClient } from "../../
|
|
3
|
+
import { ClientManager } from "../../client-manager.mjs";
|
|
4
|
+
import { AlgorandClient } from "../../algorand-client.mjs";
|
|
5
5
|
import { getTestAccount } from "../account.mjs";
|
|
6
6
|
import { runWhenIndexerCaughtUp } from "../indexer.mjs";
|
|
7
7
|
import { TransactionLogger } from "../transaction-logger.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algorand-fixture.mjs","names":["context: AlgorandTestAutomationContext","algorand: AlgorandClient"],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../
|
|
1
|
+
{"version":3,"file":"algorand-fixture.mjs","names":["context: AlgorandTestAutomationContext","algorand: AlgorandClient"],"sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":["import { algos, Config } from '../../'\nimport { AlgorandClient } from '../../algorand-client'\nimport { ClientManager } from '../../client-manager'\nimport { AlgoConfig } from '../../network-client'\nimport { getTestAccount } from '../account'\nimport { runWhenIndexerCaughtUp } from '../indexer'\nimport { TransactionLogger } from '../transaction-logger'\nimport { AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams } from '../types'\n\n/**\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd (or their respective config) if you want to test against\n * an explicitly defined network.\n *\n * @example No config (per-test isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example No config (test suite isolation)\n * ```typescript\n * const fixture = algorandFixture()\n *\n * beforeAll(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @example With config\n * ```typescript\n * const fixture = algorandFixture({\n * algod: new AlgodClient({ baseUrl: 'http://localhost:12345', headers: { 'X-Algo-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' } }),\n * // ...\n * })\n *\n * beforeEach(fixture.newScope)\n *\n * test('My test', async () => {\n * const {algod, indexer, testAccount, ...} = fixture.context\n * // test things...\n * })\n * ```\n *\n * @param fixtureConfig The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture\n\n/**\n * @deprecated Config can be passed in directly to fixture config now.\n *\n * Creates a test fixture for automated testing against Algorand.\n * By default it tests against an environment variable specified client\n * if the standard environment variables are specified, otherwise against\n * a default LocalNet instance, but you can pass in an algod, indexer\n * and/or kmd if you want to test against an explicitly defined network.\n *\n * @param fixtureConfig The fixture configuration\n * @param config The fixture configuration\n * @returns The fixture\n */\nexport function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture\n\nexport function algorandFixture(fixtureConfig?: AlgorandFixtureConfig, config?: AlgoConfig): AlgorandFixture {\n fixtureConfig = { ...fixtureConfig, ...config }\n if (!fixtureConfig.algod || !fixtureConfig.indexer || !fixtureConfig.kmd) {\n fixtureConfig = { ...ClientManager.getConfigFromEnvironmentOrLocalNet(), ...fixtureConfig }\n }\n\n const algod = fixtureConfig.algod ?? ClientManager.getAlgodClient(fixtureConfig.algodConfig!)\n const indexer = fixtureConfig.indexer ?? ClientManager.getIndexerClient(fixtureConfig.indexerConfig!)\n const kmd = fixtureConfig.kmd ?? ClientManager.getKmdClient(fixtureConfig.kmdConfig!)\n let context: AlgorandTestAutomationContext\n let algorand: AlgorandClient\n\n const newScope = async () => {\n Config.configure({ debug: true })\n const transactionLogger = new TransactionLogger()\n const transactionLoggerAlgod = transactionLogger.capture(algod)\n\n algorand = AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd }).setSuggestedParamsCacheTimeout(0)\n\n const testAccount = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, algorand)\n algorand.setSignerFromAccount(testAccount)\n\n // If running against LocalNet we are likely in dev mode and we need to set a much higher validity window\n // otherwise we are more likely to get invalid transactions.\n if (await algorand.client.isLocalNet()) {\n algorand.setDefaultValidityWindow(1000)\n }\n context = {\n algorand,\n algod: transactionLoggerAlgod,\n indexer: indexer,\n kmd: kmd,\n testAccount,\n generateAccount: async (params: GetTestAccountParams) => {\n const account = await getTestAccount(params, algorand)\n algorand.setSignerFromAccount(account)\n return account\n },\n transactionLogger: transactionLogger,\n waitForIndexer: () => transactionLogger.waitForIndexer(indexer),\n waitForIndexerTransaction: (transactionId: string) => runWhenIndexerCaughtUp(() => indexer.lookupTransactionById(transactionId)),\n }\n }\n\n return {\n get context() {\n if (!context) throw new Error('Context not initialised; make sure to call fixture.newScope() before accessing context.')\n return context\n },\n get algorand() {\n return algorand\n },\n beforeEach: newScope,\n newScope,\n }\n}\n"],"mappings":";;;;;;;;;AA4EA,SAAgB,gBAAgB,eAAuC,QAAsC;AAC3G,iBAAgB;EAAE,GAAG;EAAe,GAAG;EAAQ;AAC/C,KAAI,CAAC,cAAc,SAAS,CAAC,cAAc,WAAW,CAAC,cAAc,IACnE,iBAAgB;EAAE,GAAG,cAAc,oCAAoC;EAAE,GAAG;EAAe;CAG7F,MAAM,QAAQ,cAAc,SAAS,cAAc,eAAe,cAAc,YAAa;CAC7F,MAAM,UAAU,cAAc,WAAW,cAAc,iBAAiB,cAAc,cAAe;CACrG,MAAM,MAAM,cAAc,OAAO,cAAc,aAAa,cAAc,UAAW;CACrF,IAAIA;CACJ,IAAIC;CAEJ,MAAM,WAAW,YAAY;AAC3B,SAAO,UAAU,EAAE,OAAO,MAAM,CAAC;EACjC,MAAM,oBAAoB,IAAI,mBAAmB;EACjD,MAAM,yBAAyB,kBAAkB,QAAQ,MAAM;AAE/D,aAAW,eAAe,YAAY;GAAE,OAAO;GAAwB;GAAS;GAAK,CAAC,CAAC,+BAA+B,EAAE;EAExH,MAAM,cAAc,MAAM,eAAe;GAAE,cAAc,eAAe,sBAAsB,MAAM,GAAG;GAAE,aAAa;GAAM,EAAE,SAAS;AACvI,WAAS,qBAAqB,YAAY;AAI1C,MAAI,MAAM,SAAS,OAAO,YAAY,CACpC,UAAS,yBAAyB,IAAK;AAEzC,YAAU;GACR;GACA,OAAO;GACE;GACJ;GACL;GACA,iBAAiB,OAAO,WAAiC;IACvD,MAAM,UAAU,MAAM,eAAe,QAAQ,SAAS;AACtD,aAAS,qBAAqB,QAAQ;AACtC,WAAO;;GAEU;GACnB,sBAAsB,kBAAkB,eAAe,QAAQ;GAC/D,4BAA4B,kBAA0B,6BAA6B,QAAQ,sBAAsB,cAAc,CAAC;GACjI;;AAGH,QAAO;EACL,IAAI,UAAU;AACZ,OAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0FAA0F;AACxH,UAAO;;EAET,IAAI,WAAW;AACb,UAAO;;EAET,YAAY;EACZ;EACD"}
|
package/testing/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TestLogger } from "./test-logger.js";
|
|
2
|
+
import { AlgoKitLogCaptureFixture, AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams, LogSnapshotConfig } from "./types.js";
|
|
2
3
|
import { getTestAccount } from "./account.js";
|
|
3
4
|
import { algoKitLogCaptureFixture } from "./fixtures/algokit-log-capture-fixture.js";
|
|
4
5
|
import { algorandFixture } from "./fixtures/algorand-fixture.js";
|
|
5
6
|
import { runWhenIndexerCaughtUp } from "./indexer.js";
|
|
6
7
|
import { TransactionLogger } from "./transaction-logger.js";
|
|
7
|
-
export { TestLogger, TransactionLogger, algoKitLogCaptureFixture, algorandFixture, getTestAccount, runWhenIndexerCaughtUp };
|
|
8
|
+
export { AlgoKitLogCaptureFixture, AlgorandFixture, AlgorandFixtureConfig, AlgorandTestAutomationContext, GetTestAccountParams, LogSnapshotConfig, TestLogger, TransactionLogger, algoKitLogCaptureFixture, algorandFixture, getTestAccount, runWhenIndexerCaughtUp };
|
package/testing/test-logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-logger.js","names":["asJson"],"sources":["../../src/testing/test-logger.ts"],"sourcesContent":["import { Logger } from '../
|
|
1
|
+
{"version":3,"file":"test-logger.js","names":["asJson"],"sources":["../../src/testing/test-logger.ts"],"sourcesContent":["import { Logger } from '../logging'\nimport { asJson } from '../util'\nimport { LogSnapshotConfig } from './types'\n\n/** Exposes an AlgoKit logger which captures log messages, while wrapping an original logger.\n * This is useful for automated testing.\n */\nexport class TestLogger implements Logger {\n private originalLogger: Logger | undefined\n private logs: string[]\n\n /**\n * Create a new test logger that wraps the given logger if provided.\n * @param originalLogger The optional original logger to wrap.\n */\n constructor(originalLogger?: Logger) {\n this.originalLogger = originalLogger\n this.logs = []\n }\n\n /** Returns all logs captured thus far. */\n get capturedLogs(): string[] {\n return this.logs\n }\n\n /** Clears all logs captured so far. */\n clear() {\n this.logs = []\n }\n\n /**\n * Returns a captured log snapshot.\n * This helps ensure that the provided configuration items won't appear\n * with random values in the log snapshot, but rather will get substituted with predictable ids.\n *\n * https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic\n *\n * @example Jest Example\n * ```typescript\n * const logger = new TestLogger()\n * ...\n * expect(logger.getLogSnapshot()).toMatchSnapshot()\n * ```\n * @param config The snapshot configuration\n * @returns The snapshotted logs.\n */\n getLogSnapshot(config?: LogSnapshotConfig) {\n const { transactions: transactionIds, accounts, apps } = config ?? {}\n let snapshot = this.capturedLogs.filter(config?.filterPredicate ?? (() => true)).join('\\n')\n transactionIds?.forEach(\n (txn, id) => (snapshot = snapshot.replace(new RegExp(typeof txn === 'string' ? txn : txn.txId(), 'g'), `TXID_${id + 1}`)),\n )\n accounts?.forEach(\n (sender, id) =>\n (snapshot = snapshot.replace(\n new RegExp(typeof sender === 'string' ? sender : 'addr' in sender ? sender.addr.toString() : sender.toString(), 'g'),\n `ACCOUNT_${id + 1}`,\n )),\n )\n apps?.forEach((app, id) => (snapshot = snapshot.replace(new RegExp(`\\\\b${app.toString()}\\\\b(?! bytes)`, 'g'), `APP_${id + 1}`)))\n return snapshot\n }\n\n error(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.error(message, ...optionalParams)\n this.logs.push(`ERROR: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n warn(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.warn(message, ...optionalParams)\n this.logs.push(`WARN: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n info(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.info(message, ...optionalParams)\n this.logs.push(`INFO: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n verbose(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.verbose(message, ...optionalParams)\n this.logs.push(`VERBOSE: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n debug(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.debug(message, ...optionalParams)\n this.logs.push(`DEBUG: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n}\n"],"mappings":";;;;;;AAOA,IAAa,aAAb,MAA0C;CACxC,AAAQ;CACR,AAAQ;;;;;CAMR,YAAY,gBAAyB;AACnC,OAAK,iBAAiB;AACtB,OAAK,OAAO,EAAE;;;CAIhB,IAAI,eAAyB;AAC3B,SAAO,KAAK;;;CAId,QAAQ;AACN,OAAK,OAAO,EAAE;;;;;;;;;;;;;;;;;;CAmBhB,eAAe,QAA4B;EACzC,MAAM,EAAE,cAAc,gBAAgB,UAAU,SAAS,UAAU,EAAE;EACrE,IAAI,WAAW,KAAK,aAAa,OAAO,QAAQ,0BAA0B,MAAM,CAAC,KAAK,KAAK;AAC3F,kBAAgB,SACb,KAAK,OAAQ,WAAW,SAAS,QAAQ,IAAI,OAAO,OAAO,QAAQ,WAAW,MAAM,IAAI,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,IAAI,CACzH;AACD,YAAU,SACP,QAAQ,OACN,WAAW,SAAS,QACnB,IAAI,OAAO,OAAO,WAAW,WAAW,SAAS,UAAU,SAAS,OAAO,KAAK,UAAU,GAAG,OAAO,UAAU,EAAE,IAAI,EACpH,WAAW,KAAK,IACjB,CACJ;AACD,QAAM,SAAS,KAAK,OAAQ,WAAW,SAAS,QAAQ,IAAI,OAAO,MAAM,IAAI,UAAU,CAAC,gBAAgB,IAAI,EAAE,OAAO,KAAK,IAAI,CAAE;AAChI,SAAO;;CAGT,MAAM,SAAiB,GAAG,gBAAiC;AACzD,OAAK,gBAAgB,MAAM,SAAS,GAAG,eAAe;AACtD,OAAK,KAAK,KAAK,UAAU,UAAU,eAAe,SAAS,MAAMA,oBAAO,eAAe,KAAK,KAAK;;CAEnG,KAAK,SAAiB,GAAG,gBAAiC;AACxD,OAAK,gBAAgB,KAAK,SAAS,GAAG,eAAe;AACrD,OAAK,KAAK,KAAK,SAAS,UAAU,eAAe,SAAS,MAAMA,oBAAO,eAAe,KAAK,KAAK;;CAElG,KAAK,SAAiB,GAAG,gBAAiC;AACxD,OAAK,gBAAgB,KAAK,SAAS,GAAG,eAAe;AACrD,OAAK,KAAK,KAAK,SAAS,UAAU,eAAe,SAAS,MAAMA,oBAAO,eAAe,KAAK,KAAK;;CAElG,QAAQ,SAAiB,GAAG,gBAAiC;AAC3D,OAAK,gBAAgB,QAAQ,SAAS,GAAG,eAAe;AACxD,OAAK,KAAK,KAAK,YAAY,UAAU,eAAe,SAAS,MAAMA,oBAAO,eAAe,KAAK,KAAK;;CAErG,MAAM,SAAiB,GAAG,gBAAiC;AACzD,OAAK,gBAAgB,MAAM,SAAS,GAAG,eAAe;AACtD,OAAK,KAAK,KAAK,UAAU,UAAU,eAAe,SAAS,MAAMA,oBAAO,eAAe,KAAK,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-logger.mjs","names":[],"sources":["../../src/testing/test-logger.ts"],"sourcesContent":["import { Logger } from '../
|
|
1
|
+
{"version":3,"file":"test-logger.mjs","names":[],"sources":["../../src/testing/test-logger.ts"],"sourcesContent":["import { Logger } from '../logging'\nimport { asJson } from '../util'\nimport { LogSnapshotConfig } from './types'\n\n/** Exposes an AlgoKit logger which captures log messages, while wrapping an original logger.\n * This is useful for automated testing.\n */\nexport class TestLogger implements Logger {\n private originalLogger: Logger | undefined\n private logs: string[]\n\n /**\n * Create a new test logger that wraps the given logger if provided.\n * @param originalLogger The optional original logger to wrap.\n */\n constructor(originalLogger?: Logger) {\n this.originalLogger = originalLogger\n this.logs = []\n }\n\n /** Returns all logs captured thus far. */\n get capturedLogs(): string[] {\n return this.logs\n }\n\n /** Clears all logs captured so far. */\n clear() {\n this.logs = []\n }\n\n /**\n * Returns a captured log snapshot.\n * This helps ensure that the provided configuration items won't appear\n * with random values in the log snapshot, but rather will get substituted with predictable ids.\n *\n * https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic\n *\n * @example Jest Example\n * ```typescript\n * const logger = new TestLogger()\n * ...\n * expect(logger.getLogSnapshot()).toMatchSnapshot()\n * ```\n * @param config The snapshot configuration\n * @returns The snapshotted logs.\n */\n getLogSnapshot(config?: LogSnapshotConfig) {\n const { transactions: transactionIds, accounts, apps } = config ?? {}\n let snapshot = this.capturedLogs.filter(config?.filterPredicate ?? (() => true)).join('\\n')\n transactionIds?.forEach(\n (txn, id) => (snapshot = snapshot.replace(new RegExp(typeof txn === 'string' ? txn : txn.txId(), 'g'), `TXID_${id + 1}`)),\n )\n accounts?.forEach(\n (sender, id) =>\n (snapshot = snapshot.replace(\n new RegExp(typeof sender === 'string' ? sender : 'addr' in sender ? sender.addr.toString() : sender.toString(), 'g'),\n `ACCOUNT_${id + 1}`,\n )),\n )\n apps?.forEach((app, id) => (snapshot = snapshot.replace(new RegExp(`\\\\b${app.toString()}\\\\b(?! bytes)`, 'g'), `APP_${id + 1}`)))\n return snapshot\n }\n\n error(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.error(message, ...optionalParams)\n this.logs.push(`ERROR: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n warn(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.warn(message, ...optionalParams)\n this.logs.push(`WARN: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n info(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.info(message, ...optionalParams)\n this.logs.push(`INFO: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n verbose(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.verbose(message, ...optionalParams)\n this.logs.push(`VERBOSE: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n debug(message: string, ...optionalParams: unknown[]): void {\n this.originalLogger?.debug(message, ...optionalParams)\n this.logs.push(`DEBUG: ${message}${optionalParams.length ? ` | ${asJson(optionalParams)}` : ''}`)\n }\n}\n"],"mappings":";;;;;;AAOA,IAAa,aAAb,MAA0C;CACxC,AAAQ;CACR,AAAQ;;;;;CAMR,YAAY,gBAAyB;AACnC,OAAK,iBAAiB;AACtB,OAAK,OAAO,EAAE;;;CAIhB,IAAI,eAAyB;AAC3B,SAAO,KAAK;;;CAId,QAAQ;AACN,OAAK,OAAO,EAAE;;;;;;;;;;;;;;;;;;CAmBhB,eAAe,QAA4B;EACzC,MAAM,EAAE,cAAc,gBAAgB,UAAU,SAAS,UAAU,EAAE;EACrE,IAAI,WAAW,KAAK,aAAa,OAAO,QAAQ,0BAA0B,MAAM,CAAC,KAAK,KAAK;AAC3F,kBAAgB,SACb,KAAK,OAAQ,WAAW,SAAS,QAAQ,IAAI,OAAO,OAAO,QAAQ,WAAW,MAAM,IAAI,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,IAAI,CACzH;AACD,YAAU,SACP,QAAQ,OACN,WAAW,SAAS,QACnB,IAAI,OAAO,OAAO,WAAW,WAAW,SAAS,UAAU,SAAS,OAAO,KAAK,UAAU,GAAG,OAAO,UAAU,EAAE,IAAI,EACpH,WAAW,KAAK,IACjB,CACJ;AACD,QAAM,SAAS,KAAK,OAAQ,WAAW,SAAS,QAAQ,IAAI,OAAO,MAAM,IAAI,UAAU,CAAC,gBAAgB,IAAI,EAAE,OAAO,KAAK,IAAI,CAAE;AAChI,SAAO;;CAGT,MAAM,SAAiB,GAAG,gBAAiC;AACzD,OAAK,gBAAgB,MAAM,SAAS,GAAG,eAAe;AACtD,OAAK,KAAK,KAAK,UAAU,UAAU,eAAe,SAAS,MAAM,OAAO,eAAe,KAAK,KAAK;;CAEnG,KAAK,SAAiB,GAAG,gBAAiC;AACxD,OAAK,gBAAgB,KAAK,SAAS,GAAG,eAAe;AACrD,OAAK,KAAK,KAAK,SAAS,UAAU,eAAe,SAAS,MAAM,OAAO,eAAe,KAAK,KAAK;;CAElG,KAAK,SAAiB,GAAG,gBAAiC;AACxD,OAAK,gBAAgB,KAAK,SAAS,GAAG,eAAe;AACrD,OAAK,KAAK,KAAK,SAAS,UAAU,eAAe,SAAS,MAAM,OAAO,eAAe,KAAK,KAAK;;CAElG,QAAQ,SAAiB,GAAG,gBAAiC;AAC3D,OAAK,gBAAgB,QAAQ,SAAS,GAAG,eAAe;AACxD,OAAK,KAAK,KAAK,YAAY,UAAU,eAAe,SAAS,MAAM,OAAO,eAAe,KAAK,KAAK;;CAErG,MAAM,SAAiB,GAAG,gBAAiC;AACzD,OAAK,gBAAgB,MAAM,SAAS,GAAG,eAAe;AACtD,OAAK,KAAK,KAAK,UAAU,UAAU,eAAe,SAAS,MAAM,OAAO,eAAe,KAAK,KAAK"}
|