@algorandfoundation/algokit-utils 10.0.0-alpha.20 → 10.0.0-alpha.21

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.
Files changed (116) hide show
  1. package/package.json +1 -6
  2. package/packages/algo25/src/index.js +1 -1
  3. package/packages/algo25/src/index.mjs +1 -1
  4. package/packages/common/src/json.mjs +2 -2
  5. package/packages/common/src/json.mjs.map +1 -1
  6. package/packages/{sdk/src/logic → common/src}/sourcemap.d.ts +2 -2
  7. package/packages/{sdk/src/logic → common/src}/sourcemap.js +2 -2
  8. package/packages/{sdk/src/logic → common/src}/sourcemap.js.map +1 -1
  9. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs +1 -1
  10. package/packages/{sdk/src/logic → common/src}/sourcemap.mjs.map +1 -1
  11. package/testing/transaction-logger.js +1 -1
  12. package/testing/transaction-logger.mjs +1 -1
  13. package/transactions/app-call.js +1 -1
  14. package/transactions/app-call.mjs +1 -1
  15. package/transactions/method-call.js +1 -1
  16. package/transactions/method-call.mjs +1 -1
  17. package/types/account-manager.js +3 -3
  18. package/types/account-manager.mjs +3 -3
  19. package/types/algorand-client-transaction-creator.d.ts +18 -18
  20. package/types/algorand-client-transaction-sender.d.ts +18 -18
  21. package/types/amount.js +23 -4
  22. package/types/amount.js.map +1 -1
  23. package/types/amount.mjs +20 -2
  24. package/types/amount.mjs.map +1 -1
  25. package/types/app-client.d.ts +64 -64
  26. package/types/app-client.js +2 -2
  27. package/types/app-client.js.map +1 -1
  28. package/types/app-client.mjs +2 -2
  29. package/types/app-client.mjs.map +1 -1
  30. package/types/app-deployer.js +1 -1
  31. package/types/app-deployer.mjs +1 -1
  32. package/types/app-factory.d.ts +26 -26
  33. package/types/app-factory.js +2 -2
  34. package/types/app-factory.js.map +1 -1
  35. package/types/app-factory.mjs +2 -2
  36. package/types/app-factory.mjs.map +1 -1
  37. package/types/app-manager.js +1 -1
  38. package/types/app-manager.js.map +1 -1
  39. package/types/app-manager.mjs +1 -1
  40. package/types/app-manager.mjs.map +1 -1
  41. package/types/app.d.ts +1 -1
  42. package/types/app.js.map +1 -1
  43. package/types/app.mjs.map +1 -1
  44. package/types/composer.js +20 -20
  45. package/types/composer.js.map +1 -1
  46. package/types/composer.mjs +4 -4
  47. package/types/kmd-account-manager.js +1 -1
  48. package/types/kmd-account-manager.mjs +1 -1
  49. package/packages/sdk/src/convert.d.ts +0 -17
  50. package/packages/sdk/src/convert.js +0 -28
  51. package/packages/sdk/src/convert.js.map +0 -1
  52. package/packages/sdk/src/convert.mjs +0 -25
  53. package/packages/sdk/src/convert.mjs.map +0 -1
  54. package/packages/sdk/src/encoding/binarydata.d.ts +0 -34
  55. package/packages/sdk/src/encoding/binarydata.js +0 -65
  56. package/packages/sdk/src/encoding/binarydata.js.map +0 -1
  57. package/packages/sdk/src/encoding/binarydata.mjs +0 -60
  58. package/packages/sdk/src/encoding/binarydata.mjs.map +0 -1
  59. package/packages/sdk/src/encoding/encoding.d.ts +0 -237
  60. package/packages/sdk/src/encoding/encoding.js +0 -312
  61. package/packages/sdk/src/encoding/encoding.js.map +0 -1
  62. package/packages/sdk/src/encoding/encoding.mjs +0 -298
  63. package/packages/sdk/src/encoding/encoding.mjs.map +0 -1
  64. package/packages/sdk/src/encoding/schema/array.js +0 -35
  65. package/packages/sdk/src/encoding/schema/array.js.map +0 -1
  66. package/packages/sdk/src/encoding/schema/array.mjs +0 -35
  67. package/packages/sdk/src/encoding/schema/array.mjs.map +0 -1
  68. package/packages/sdk/src/encoding/schema/bytearray.js +0 -49
  69. package/packages/sdk/src/encoding/schema/bytearray.js.map +0 -1
  70. package/packages/sdk/src/encoding/schema/bytearray.mjs +0 -49
  71. package/packages/sdk/src/encoding/schema/bytearray.mjs.map +0 -1
  72. package/packages/sdk/src/encoding/schema/map.d.ts +0 -58
  73. package/packages/sdk/src/encoding/schema/map.js +0 -108
  74. package/packages/sdk/src/encoding/schema/map.js.map +0 -1
  75. package/packages/sdk/src/encoding/schema/map.mjs +0 -107
  76. package/packages/sdk/src/encoding/schema/map.mjs.map +0 -1
  77. package/packages/sdk/src/encoding/schema/optional.js +0 -46
  78. package/packages/sdk/src/encoding/schema/optional.js.map +0 -1
  79. package/packages/sdk/src/encoding/schema/optional.mjs +0 -46
  80. package/packages/sdk/src/encoding/schema/optional.mjs.map +0 -1
  81. package/packages/sdk/src/encoding/schema/uint64.js +0 -30
  82. package/packages/sdk/src/encoding/schema/uint64.js.map +0 -1
  83. package/packages/sdk/src/encoding/schema/uint64.mjs +0 -30
  84. package/packages/sdk/src/encoding/schema/uint64.mjs.map +0 -1
  85. package/packages/sdk/src/encoding/uint64.d.ts +0 -34
  86. package/packages/sdk/src/encoding/uint64.js +0 -34
  87. package/packages/sdk/src/encoding/uint64.js.map +0 -1
  88. package/packages/sdk/src/encoding/uint64.mjs +0 -33
  89. package/packages/sdk/src/encoding/uint64.mjs.map +0 -1
  90. package/packages/sdk/src/index.d.ts +0 -44
  91. package/packages/sdk/src/index.js +0 -62
  92. package/packages/sdk/src/index.js.map +0 -1
  93. package/packages/sdk/src/index.mjs +0 -58
  94. package/packages/sdk/src/index.mjs.map +0 -1
  95. package/packages/sdk/src/nacl/naclWrappers.js +0 -14
  96. package/packages/sdk/src/nacl/naclWrappers.js.map +0 -1
  97. package/packages/sdk/src/nacl/naclWrappers.mjs +0 -11
  98. package/packages/sdk/src/nacl/naclWrappers.mjs.map +0 -1
  99. package/packages/sdk/src/types/intDecoding.d.ts +0 -28
  100. package/packages/sdk/src/types/intDecoding.js +0 -32
  101. package/packages/sdk/src/types/intDecoding.js.map +0 -1
  102. package/packages/sdk/src/types/intDecoding.mjs +0 -31
  103. package/packages/sdk/src/types/intDecoding.mjs.map +0 -1
  104. package/packages/sdk/src/types/transactions/encoded.d.ts +0 -40
  105. package/packages/sdk/src/types/transactions/encoded.js +0 -64
  106. package/packages/sdk/src/types/transactions/encoded.js.map +0 -1
  107. package/packages/sdk/src/types/transactions/encoded.mjs +0 -59
  108. package/packages/sdk/src/types/transactions/encoded.mjs.map +0 -1
  109. package/packages/sdk/src/utils/utils.d.ts +0 -64
  110. package/packages/sdk/src/utils/utils.js +0 -140
  111. package/packages/sdk/src/utils/utils.js.map +0 -1
  112. package/packages/sdk/src/utils/utils.mjs +0 -128
  113. package/packages/sdk/src/utils/utils.mjs.map +0 -1
  114. package/sdk/index.d.ts +0 -10
  115. package/sdk/index.js +0 -59
  116. package/sdk/index.mjs +0 -11
@@ -1,25 +0,0 @@
1
- //#region packages/sdk/src/convert.ts
2
- const MICROALGOS_TO_ALGOS_RATIO = 1e6;
3
- const INVALID_MICROALGOS_ERROR_MSG = "Microalgos should be positive and less than 2^53 - 1.";
4
- /**
5
- * microalgosToAlgos converts microalgos to algos
6
- * @param microalgos - number
7
- * @returns number
8
- */
9
- function microalgosToAlgos(microalgos) {
10
- if (microalgos < 0 || !Number.isSafeInteger(microalgos)) throw new Error(INVALID_MICROALGOS_ERROR_MSG);
11
- return microalgos / MICROALGOS_TO_ALGOS_RATIO;
12
- }
13
- /**
14
- * algosToMicroalgos converts algos to microalgos
15
- * @param algos - number
16
- * @returns number
17
- */
18
- function algosToMicroalgos(algos) {
19
- const microalgos = algos * MICROALGOS_TO_ALGOS_RATIO;
20
- return Math.round(microalgos);
21
- }
22
-
23
- //#endregion
24
- export { INVALID_MICROALGOS_ERROR_MSG, algosToMicroalgos, microalgosToAlgos };
25
- //# sourceMappingURL=convert.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert.mjs","names":[],"sources":["../../../../packages/sdk/src/convert.ts"],"sourcesContent":["const MICROALGOS_TO_ALGOS_RATIO = 1e6\nexport const INVALID_MICROALGOS_ERROR_MSG = 'Microalgos should be positive and less than 2^53 - 1.'\n\n/**\n * microalgosToAlgos converts microalgos to algos\n * @param microalgos - number\n * @returns number\n */\nexport function microalgosToAlgos(microalgos: number) {\n if (microalgos < 0 || !Number.isSafeInteger(microalgos)) {\n throw new Error(INVALID_MICROALGOS_ERROR_MSG)\n }\n return microalgos / MICROALGOS_TO_ALGOS_RATIO\n}\n\n/**\n * algosToMicroalgos converts algos to microalgos\n * @param algos - number\n * @returns number\n */\nexport function algosToMicroalgos(algos: number) {\n const microalgos = algos * MICROALGOS_TO_ALGOS_RATIO\n return Math.round(microalgos)\n}\n"],"mappings":";AAAA,MAAM,4BAA4B;AAClC,MAAa,+BAA+B;;;;;;AAO5C,SAAgB,kBAAkB,YAAoB;AACpD,KAAI,aAAa,KAAK,CAAC,OAAO,cAAc,WAAW,CACrD,OAAM,IAAI,MAAM,6BAA6B;AAE/C,QAAO,aAAa;;;;;;;AAQtB,SAAgB,kBAAkB,OAAe;CAC/C,MAAM,aAAa,QAAQ;AAC3B,QAAO,KAAK,MAAM,WAAW"}
@@ -1,34 +0,0 @@
1
- //#region packages/sdk/src/encoding/binarydata.d.ts
2
- /**
3
- * Convert a base64 string to a Uint8Array for Node.js and browser environments.
4
- * @returns A Uint8Array
5
- */
6
- declare function base64ToBytes(base64String: string): Uint8Array;
7
- /**
8
- * Convert a Uint8Array to a base64 string for Node.js and browser environments.
9
- * @returns A base64 string
10
- */
11
- declare function bytesToBase64(byteArray: Uint8Array): string;
12
- /**
13
- * Convert a byte array to a UTF-8 string. Warning: not all byte arrays are valid UTF-8.
14
- * @returns A decoded string
15
- */
16
- declare function bytesToString(byteArray: Uint8Array): string;
17
- /**
18
- * Returns a Uint8Array given an input string or Uint8Array.
19
- * @returns A base64 string
20
- */
21
- declare function coerceToBytes(input: Uint8Array | string): Uint8Array;
22
- /**
23
- * Convert a Uint8Array to a hex string for Node.js and browser environments.
24
- * @returns A hex string
25
- */
26
- declare function bytesToHex(byteArray: Uint8Array): string;
27
- /**
28
- * Convert a hex string to Uint8Array for Node.js and browser environments.
29
- * @returns A Uint8Array
30
- */
31
- declare function hexToBytes(hexString: string): Uint8Array;
32
- //#endregion
33
- export { base64ToBytes, bytesToBase64, bytesToHex, bytesToString, coerceToBytes, hexToBytes };
34
- //# sourceMappingURL=binarydata.d.ts.map
@@ -1,65 +0,0 @@
1
- const require_utils = require('../utils/utils.js');
2
-
3
- //#region packages/sdk/src/encoding/binarydata.ts
4
- /**
5
- * Convert a base64 string to a Uint8Array for Node.js and browser environments.
6
- * @returns A Uint8Array
7
- */
8
- function base64ToBytes(base64String) {
9
- if (require_utils.isNode()) return new Uint8Array(Buffer.from(base64String, "base64"));
10
- const binString = atob(base64String);
11
- return Uint8Array.from(binString, (m) => m.codePointAt(0));
12
- }
13
- /**
14
- * Convert a Uint8Array to a base64 string for Node.js and browser environments.
15
- * @returns A base64 string
16
- */
17
- function bytesToBase64(byteArray) {
18
- if (require_utils.isNode()) return Buffer.from(byteArray).toString("base64");
19
- const binString = Array.from(byteArray, (x) => String.fromCodePoint(x)).join("");
20
- return btoa(binString);
21
- }
22
- /**
23
- * Convert a byte array to a UTF-8 string. Warning: not all byte arrays are valid UTF-8.
24
- * @returns A decoded string
25
- */
26
- function bytesToString(byteArray) {
27
- return new TextDecoder().decode(byteArray);
28
- }
29
- /**
30
- * Returns a Uint8Array given an input string or Uint8Array.
31
- * @returns A base64 string
32
- */
33
- function coerceToBytes(input) {
34
- if (typeof input === "string") return new TextEncoder().encode(input);
35
- return input;
36
- }
37
- /**
38
- * Convert a Uint8Array to a hex string for Node.js and browser environments.
39
- * @returns A hex string
40
- */
41
- function bytesToHex(byteArray) {
42
- if (require_utils.isNode()) return Buffer.from(byteArray).toString("hex");
43
- return Array.from(byteArray).map((i) => i.toString(16).padStart(2, "0")).join("");
44
- }
45
- /**
46
- * Convert a hex string to Uint8Array for Node.js and browser environments.
47
- * @returns A Uint8Array
48
- */
49
- function hexToBytes(hexString) {
50
- if (require_utils.isNode()) return Buffer.from(hexString, "hex");
51
- let hex = hexString;
52
- if (hexString.length % 2 !== 0) hex = hexString.padStart(1, "0");
53
- const byteArray = new Uint8Array(hex.length / 2);
54
- for (let i = 0; i < hex.length / 2; i++) byteArray[i] = parseInt(hex.slice(2 * i, 2 * i + 2), 16);
55
- return byteArray;
56
- }
57
-
58
- //#endregion
59
- exports.base64ToBytes = base64ToBytes;
60
- exports.bytesToBase64 = bytesToBase64;
61
- exports.bytesToHex = bytesToHex;
62
- exports.bytesToString = bytesToString;
63
- exports.coerceToBytes = coerceToBytes;
64
- exports.hexToBytes = hexToBytes;
65
- //# sourceMappingURL=binarydata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"binarydata.js","names":["isNode"],"sources":["../../../../../packages/sdk/src/encoding/binarydata.ts"],"sourcesContent":["import { isNode } from '../utils/utils.js'\n\n/**\n * Convert a base64 string to a Uint8Array for Node.js and browser environments.\n * @returns A Uint8Array\n */\nexport function base64ToBytes(base64String: string): Uint8Array {\n if (isNode()) {\n return new Uint8Array(Buffer.from(base64String, 'base64'))\n }\n /* eslint-env browser */\n const binString = atob(base64String)\n return Uint8Array.from(binString, (m) => m.codePointAt(0)!)\n}\n\n/**\n * Convert a Uint8Array to a base64 string for Node.js and browser environments.\n * @returns A base64 string\n */\nexport function bytesToBase64(byteArray: Uint8Array): string {\n if (isNode()) {\n return Buffer.from(byteArray).toString('base64')\n }\n /* eslint-env browser */\n const binString = Array.from(byteArray, (x) => String.fromCodePoint(x)).join('')\n return btoa(binString)\n}\n\n/**\n * Convert a byte array to a UTF-8 string. Warning: not all byte arrays are valid UTF-8.\n * @returns A decoded string\n */\nexport function bytesToString(byteArray: Uint8Array): string {\n return new TextDecoder().decode(byteArray)\n}\n\n/**\n * Returns a Uint8Array given an input string or Uint8Array.\n * @returns A base64 string\n */\nexport function coerceToBytes(input: Uint8Array | string): Uint8Array {\n if (typeof input === 'string') {\n return new TextEncoder().encode(input)\n }\n return input\n}\n\n/**\n * Convert a Uint8Array to a hex string for Node.js and browser environments.\n * @returns A hex string\n */\nexport function bytesToHex(byteArray: Uint8Array): string {\n if (isNode()) {\n return Buffer.from(byteArray).toString('hex')\n }\n return Array.from(byteArray)\n .map((i) => i.toString(16).padStart(2, '0'))\n .join('')\n}\n\n/**\n * Convert a hex string to Uint8Array for Node.js and browser environments.\n * @returns A Uint8Array\n */\nexport function hexToBytes(hexString: string): Uint8Array {\n if (isNode()) {\n return Buffer.from(hexString, 'hex')\n }\n let hex = hexString\n if (hexString.length % 2 !== 0) {\n hex = hexString.padStart(1, '0')\n }\n const byteArray = new Uint8Array(hex.length / 2)\n for (let i = 0; i < hex.length / 2; i++) {\n byteArray[i] = parseInt(hex.slice(2 * i, 2 * i + 2), 16)\n }\n return byteArray\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,cAAc,cAAkC;AAC9D,KAAIA,sBAAQ,CACV,QAAO,IAAI,WAAW,OAAO,KAAK,cAAc,SAAS,CAAC;CAG5D,MAAM,YAAY,KAAK,aAAa;AACpC,QAAO,WAAW,KAAK,YAAY,MAAM,EAAE,YAAY,EAAE,CAAE;;;;;;AAO7D,SAAgB,cAAc,WAA+B;AAC3D,KAAIA,sBAAQ,CACV,QAAO,OAAO,KAAK,UAAU,CAAC,SAAS,SAAS;CAGlD,MAAM,YAAY,MAAM,KAAK,YAAY,MAAM,OAAO,cAAc,EAAE,CAAC,CAAC,KAAK,GAAG;AAChF,QAAO,KAAK,UAAU;;;;;;AAOxB,SAAgB,cAAc,WAA+B;AAC3D,QAAO,IAAI,aAAa,CAAC,OAAO,UAAU;;;;;;AAO5C,SAAgB,cAAc,OAAwC;AACpE,KAAI,OAAO,UAAU,SACnB,QAAO,IAAI,aAAa,CAAC,OAAO,MAAM;AAExC,QAAO;;;;;;AAOT,SAAgB,WAAW,WAA+B;AACxD,KAAIA,sBAAQ,CACV,QAAO,OAAO,KAAK,UAAU,CAAC,SAAS,MAAM;AAE/C,QAAO,MAAM,KAAK,UAAU,CACzB,KAAK,MAAM,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAC3C,KAAK,GAAG;;;;;;AAOb,SAAgB,WAAW,WAA+B;AACxD,KAAIA,sBAAQ,CACV,QAAO,OAAO,KAAK,WAAW,MAAM;CAEtC,IAAI,MAAM;AACV,KAAI,UAAU,SAAS,MAAM,EAC3B,OAAM,UAAU,SAAS,GAAG,IAAI;CAElC,MAAM,YAAY,IAAI,WAAW,IAAI,SAAS,EAAE;AAChD,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,SAAS,GAAG,IAClC,WAAU,KAAK,SAAS,IAAI,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,EAAE,GAAG;AAE1D,QAAO"}
@@ -1,60 +0,0 @@
1
- import { isNode } from "../utils/utils.mjs";
2
-
3
- //#region packages/sdk/src/encoding/binarydata.ts
4
- /**
5
- * Convert a base64 string to a Uint8Array for Node.js and browser environments.
6
- * @returns A Uint8Array
7
- */
8
- function base64ToBytes(base64String) {
9
- if (isNode()) return new Uint8Array(Buffer.from(base64String, "base64"));
10
- const binString = atob(base64String);
11
- return Uint8Array.from(binString, (m) => m.codePointAt(0));
12
- }
13
- /**
14
- * Convert a Uint8Array to a base64 string for Node.js and browser environments.
15
- * @returns A base64 string
16
- */
17
- function bytesToBase64(byteArray) {
18
- if (isNode()) return Buffer.from(byteArray).toString("base64");
19
- const binString = Array.from(byteArray, (x) => String.fromCodePoint(x)).join("");
20
- return btoa(binString);
21
- }
22
- /**
23
- * Convert a byte array to a UTF-8 string. Warning: not all byte arrays are valid UTF-8.
24
- * @returns A decoded string
25
- */
26
- function bytesToString(byteArray) {
27
- return new TextDecoder().decode(byteArray);
28
- }
29
- /**
30
- * Returns a Uint8Array given an input string or Uint8Array.
31
- * @returns A base64 string
32
- */
33
- function coerceToBytes(input) {
34
- if (typeof input === "string") return new TextEncoder().encode(input);
35
- return input;
36
- }
37
- /**
38
- * Convert a Uint8Array to a hex string for Node.js and browser environments.
39
- * @returns A hex string
40
- */
41
- function bytesToHex(byteArray) {
42
- if (isNode()) return Buffer.from(byteArray).toString("hex");
43
- return Array.from(byteArray).map((i) => i.toString(16).padStart(2, "0")).join("");
44
- }
45
- /**
46
- * Convert a hex string to Uint8Array for Node.js and browser environments.
47
- * @returns A Uint8Array
48
- */
49
- function hexToBytes(hexString) {
50
- if (isNode()) return Buffer.from(hexString, "hex");
51
- let hex = hexString;
52
- if (hexString.length % 2 !== 0) hex = hexString.padStart(1, "0");
53
- const byteArray = new Uint8Array(hex.length / 2);
54
- for (let i = 0; i < hex.length / 2; i++) byteArray[i] = parseInt(hex.slice(2 * i, 2 * i + 2), 16);
55
- return byteArray;
56
- }
57
-
58
- //#endregion
59
- export { base64ToBytes, bytesToBase64, bytesToHex, bytesToString, coerceToBytes, hexToBytes };
60
- //# sourceMappingURL=binarydata.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"binarydata.mjs","names":[],"sources":["../../../../../packages/sdk/src/encoding/binarydata.ts"],"sourcesContent":["import { isNode } from '../utils/utils.js'\n\n/**\n * Convert a base64 string to a Uint8Array for Node.js and browser environments.\n * @returns A Uint8Array\n */\nexport function base64ToBytes(base64String: string): Uint8Array {\n if (isNode()) {\n return new Uint8Array(Buffer.from(base64String, 'base64'))\n }\n /* eslint-env browser */\n const binString = atob(base64String)\n return Uint8Array.from(binString, (m) => m.codePointAt(0)!)\n}\n\n/**\n * Convert a Uint8Array to a base64 string for Node.js and browser environments.\n * @returns A base64 string\n */\nexport function bytesToBase64(byteArray: Uint8Array): string {\n if (isNode()) {\n return Buffer.from(byteArray).toString('base64')\n }\n /* eslint-env browser */\n const binString = Array.from(byteArray, (x) => String.fromCodePoint(x)).join('')\n return btoa(binString)\n}\n\n/**\n * Convert a byte array to a UTF-8 string. Warning: not all byte arrays are valid UTF-8.\n * @returns A decoded string\n */\nexport function bytesToString(byteArray: Uint8Array): string {\n return new TextDecoder().decode(byteArray)\n}\n\n/**\n * Returns a Uint8Array given an input string or Uint8Array.\n * @returns A base64 string\n */\nexport function coerceToBytes(input: Uint8Array | string): Uint8Array {\n if (typeof input === 'string') {\n return new TextEncoder().encode(input)\n }\n return input\n}\n\n/**\n * Convert a Uint8Array to a hex string for Node.js and browser environments.\n * @returns A hex string\n */\nexport function bytesToHex(byteArray: Uint8Array): string {\n if (isNode()) {\n return Buffer.from(byteArray).toString('hex')\n }\n return Array.from(byteArray)\n .map((i) => i.toString(16).padStart(2, '0'))\n .join('')\n}\n\n/**\n * Convert a hex string to Uint8Array for Node.js and browser environments.\n * @returns A Uint8Array\n */\nexport function hexToBytes(hexString: string): Uint8Array {\n if (isNode()) {\n return Buffer.from(hexString, 'hex')\n }\n let hex = hexString\n if (hexString.length % 2 !== 0) {\n hex = hexString.padStart(1, '0')\n }\n const byteArray = new Uint8Array(hex.length / 2)\n for (let i = 0; i < hex.length / 2; i++) {\n byteArray[i] = parseInt(hex.slice(2 * i, 2 * i + 2), 16)\n }\n return byteArray\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,cAAc,cAAkC;AAC9D,KAAI,QAAQ,CACV,QAAO,IAAI,WAAW,OAAO,KAAK,cAAc,SAAS,CAAC;CAG5D,MAAM,YAAY,KAAK,aAAa;AACpC,QAAO,WAAW,KAAK,YAAY,MAAM,EAAE,YAAY,EAAE,CAAE;;;;;;AAO7D,SAAgB,cAAc,WAA+B;AAC3D,KAAI,QAAQ,CACV,QAAO,OAAO,KAAK,UAAU,CAAC,SAAS,SAAS;CAGlD,MAAM,YAAY,MAAM,KAAK,YAAY,MAAM,OAAO,cAAc,EAAE,CAAC,CAAC,KAAK,GAAG;AAChF,QAAO,KAAK,UAAU;;;;;;AAOxB,SAAgB,cAAc,WAA+B;AAC3D,QAAO,IAAI,aAAa,CAAC,OAAO,UAAU;;;;;;AAO5C,SAAgB,cAAc,OAAwC;AACpE,KAAI,OAAO,UAAU,SACnB,QAAO,IAAI,aAAa,CAAC,OAAO,MAAM;AAExC,QAAO;;;;;;AAOT,SAAgB,WAAW,WAA+B;AACxD,KAAI,QAAQ,CACV,QAAO,OAAO,KAAK,UAAU,CAAC,SAAS,MAAM;AAE/C,QAAO,MAAM,KAAK,UAAU,CACzB,KAAK,MAAM,EAAE,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAC3C,KAAK,GAAG;;;;;;AAOb,SAAgB,WAAW,WAA+B;AACxD,KAAI,QAAQ,CACV,QAAO,OAAO,KAAK,WAAW,MAAM;CAEtC,IAAI,MAAM;AACV,KAAI,UAAU,SAAS,MAAM,EAC3B,OAAM,UAAU,SAAS,GAAG,IAAI;CAElC,MAAM,YAAY,IAAI,WAAW,IAAI,SAAS,EAAE;AAChD,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,SAAS,GAAG,IAClC,WAAU,KAAK,SAAS,IAAI,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,EAAE,GAAG;AAE1D,QAAO"}
@@ -1,237 +0,0 @@
1
- import { IntDecoding } from "../types/intDecoding.js";
2
- import { RawBinaryString } from "algorand-msgpack";
3
-
4
- //#region packages/sdk/src/encoding/encoding.d.ts
5
-
6
- declare const ERROR_CONTAINS_EMPTY_STRING = "The object contains empty or 0 values. First empty or 0 value encountered during encoding: ";
7
- /**
8
- * msgpackRawEncode encodes objects using msgpack, regardless of whether there are
9
- * empty or 0 value fields.
10
- * @param obj - a dictionary to be encoded. May or may not contain empty or 0 values.
11
- * @returns msgpack representation of the object
12
- */
13
- declare function msgpackRawEncode(obj: unknown): Uint8Array;
14
- /**
15
- * encodeObj takes a javascript object and returns its msgpack encoding
16
- * Note that the encoding sorts the fields alphabetically
17
- * @param o - js object to be encoded. Must not contain empty or 0 values.
18
- * @returns Uint8Array binary representation
19
- * @throws Error containing ERROR_CONTAINS_EMPTY_STRING if the object contains empty or zero values
20
- *
21
- * @deprecated Use {@link msgpackRawEncode} instead. Note that function does not
22
- * check for empty values like this one does.
23
- */
24
- declare function encodeObj(obj: Record<string | number | symbol, any>): Uint8Array;
25
- /**
26
- * Decodes msgpack bytes into a plain JavaScript object.
27
- * @param buffer - The msgpack bytes to decode
28
- * @param options - Options for decoding, including int decoding mode. See {@link IntDecoding} for more information.
29
- * @returns The decoded object
30
- */
31
- declare function msgpackRawDecode(buffer: ArrayLike<number>, options?: {
32
- intDecoding: IntDecoding;
33
- }): unknown;
34
- /**
35
- * decodeObj takes a Uint8Array and returns its javascript obj
36
- * @param o - Uint8Array to decode
37
- * @returns object
38
- *
39
- * @deprecated Use {@link msgpackRawDecode} instead. Note that this function uses `IntDecoding.MIXED`
40
- * while `msgpackRawDecode` defaults to `IntDecoding.BIGINT` for int decoding, though it is
41
- * configurable.
42
- */
43
- declare function decodeObj(o: ArrayLike<number>): unknown;
44
- /**
45
- * Decodes msgpack bytes into a Map object. This supports decoding non-string map keys.
46
- * @param encoded - The msgpack bytes to decode
47
- * @param options - Options for decoding, including int decoding mode. See {@link IntDecoding} for more information.
48
- * @returns The decoded Map object
49
- */
50
- declare function msgpackRawDecodeAsMap(encoded: ArrayLike<number>, options?: {
51
- intDecoding: IntDecoding;
52
- }): unknown;
53
- type MsgpackEncodingData = null | undefined | string | number | bigint | boolean | Uint8Array | MsgpackEncodingData[] | Map<string | number | bigint | Uint8Array, MsgpackEncodingData>;
54
- type JSONEncodingData = null | undefined | string | number | bigint | boolean | JSONEncodingData[] | {
55
- [key: string]: JSONEncodingData;
56
- };
57
- declare function msgpackEncodingDataToJSONEncodingData(e: MsgpackEncodingData): JSONEncodingData;
58
- declare function jsonEncodingDataToMsgpackEncodingData(e: JSONEncodingData): MsgpackEncodingData;
59
- declare enum MsgpackObjectPathSegmentKind {
60
- MAP_VALUE = 0,
61
- ARRAY_ELEMENT = 1,
62
- }
63
- interface MsgpackObjectPathSegment {
64
- kind: MsgpackObjectPathSegmentKind;
65
- key: string | number | bigint | Uint8Array | RawBinaryString;
66
- }
67
- /**
68
- * This class is used to index into an encoded msgpack object and extract raw strings.
69
- */
70
- declare class MsgpackRawStringProvider {
71
- private readonly parent?;
72
- private readonly baseObjectBytes?;
73
- private readonly segment?;
74
- private resolvedCache;
75
- private resolvedCachePresent;
76
- constructor({
77
- parent,
78
- segment,
79
- baseObjectBytes
80
- }: {
81
- parent: MsgpackRawStringProvider;
82
- segment: MsgpackObjectPathSegment;
83
- baseObjectBytes?: undefined;
84
- } | {
85
- parent?: undefined;
86
- segment?: undefined;
87
- baseObjectBytes: ArrayLike<number>;
88
- });
89
- /**
90
- * Create a new provider that resolves to the current provider's map value at the given key.
91
- */
92
- withMapValue(key: string | number | bigint | Uint8Array | RawBinaryString): MsgpackRawStringProvider;
93
- /**
94
- * Create a new provider that resolves to the current provider's array element at the given index.
95
- */
96
- withArrayElement(index: number): MsgpackRawStringProvider;
97
- /**
98
- * Get the raw string at the current location. If the current location is not a raw string, an error is thrown.
99
- */
100
- getRawStringAtCurrentLocation(): Uint8Array;
101
- /**
102
- * Get the raw string map keys and values at the current location. If the current location is not a map, an error is thrown.
103
- */
104
- getRawStringKeysAndValuesAtCurrentLocation(): Map<Uint8Array, MsgpackEncodingData>;
105
- /**
106
- * Resolve the provider by extracting the value it indicates from the base msgpack object.
107
- */
108
- private resolve;
109
- /**
110
- * Get the path string of the current location indicated by the provider. Useful for debugging.
111
- */
112
- getPathString(): string;
113
- }
114
- /**
115
- * Options for {@link Schema.prepareJSON}
116
- */
117
- interface PrepareJSONOptions {
118
- /**
119
- * If true, allows invalid UTF-8 binary strings to be converted to JSON strings.
120
- *
121
- * Otherwise, an error will be thrown if encoding a binary string to a JSON cannot be done losslessly.
122
- */
123
- lossyBinaryStringConversion?: boolean;
124
- }
125
- /**
126
- * A Schema is used to prepare objects for encoding and decoding from msgpack and JSON.
127
- *
128
- * Schemas represent a specific type.
129
- */
130
- declare abstract class Schema {
131
- /**
132
- * Get the default value for this type.
133
- */
134
- abstract defaultValue(): unknown;
135
- /**
136
- * Checks if the value is the default value for this type.
137
- * @param data - The value to check
138
- * @returns True if the value is the default value, false otherwise
139
- */
140
- abstract isDefaultValue(data: unknown): boolean;
141
- /**
142
- * Prepares the encoding data for encoding to msgpack.
143
- * @param data - Encoding data to be prepared.
144
- * @returns A value ready to be msgpack encoded.
145
- */
146
- abstract prepareMsgpack(data: unknown): MsgpackEncodingData;
147
- /**
148
- * Restores the encoding data from a msgpack encoding object.
149
- * @param encoded - The msgpack encoding object to restore.
150
- * @param rawStringProvider - A provider for raw strings.
151
- * @returns The original encoding data.
152
- */
153
- abstract fromPreparedMsgpack(encoded: MsgpackEncodingData, rawStringProvider: MsgpackRawStringProvider): unknown;
154
- /**
155
- * Prepares the encoding data for encoding to JSON.
156
- * @param data - The JSON encoding data to be prepared.
157
- * @returns A value ready to be JSON encoded.
158
- */
159
- abstract prepareJSON(data: unknown, options: PrepareJSONOptions): JSONEncodingData;
160
- /**
161
- * Restores the encoding data from a JSON encoding object.
162
- * @param encoded - The JSON encoding object to restore.
163
- * @returns The original encoding data.
164
- */
165
- abstract fromPreparedJSON(encoded: JSONEncodingData): unknown;
166
- }
167
- /**
168
- * An interface for objects that can be encoded and decoded to/from msgpack and JSON.
169
- */
170
- interface Encodable {
171
- /**
172
- * Extract the encoding data for this object. This data, after being prepared by the encoding
173
- * Schema, can be encoded to msgpack or JSON.
174
- */
175
- toEncodingData(): unknown;
176
- /**
177
- * Get the encoding Schema for this object, used to prepare the encoding data for msgpack and JSON.
178
- */
179
- getEncodingSchema(): Schema;
180
- }
181
- /**
182
- * A type that represents the class of an Encodable object.
183
- */
184
- interface EncodableClass<T extends Encodable> {
185
- /**
186
- * Create a new instance of this class from the given encoding data.
187
- * @param data - The encoding data to create the object from
188
- */
189
- fromEncodingData(data: unknown): T;
190
- /**
191
- * The encoding Schema for this class, used to prepare encoding data from msgpack and JSON.
192
- */
193
- readonly encodingSchema: Schema;
194
- }
195
- /**
196
- * Decode a msgpack byte array to an Encodable object.
197
- * @param encoded - The msgpack bytes to decode
198
- * @param c - The class of the object to decode. This class must match the object that was encoded.
199
- * @returns An instance of the class with the decoded data
200
- */
201
- declare function decodeMsgpack<T extends Encodable>(encoded: ArrayLike<number>, c: EncodableClass<T>): T;
202
- /**
203
- * Encode an Encodable object to a msgpack byte array.
204
- * @param e - The object to encode
205
- * @returns A msgpack byte array encoding of the object
206
- */
207
- declare function encodeMsgpack(e: Encodable): Uint8Array;
208
- /**
209
- * Decode a JSON string to an Encodable object.
210
- * @param encoded - The JSON string to decode
211
- * @param c - The class of the object to decode. This class must match the object that was encoded.
212
- * @returns An instance of the class with the decoded data
213
- */
214
- declare function decodeJSON<T extends Encodable>(encoded: string, c: EncodableClass<T>): T;
215
- interface EncodeJSONOptions {
216
- /**
217
- * Adds indentation, white space, and line break characters to the return-value JSON text to make
218
- * it easier to read.
219
- */
220
- space?: string | number;
221
- /**
222
- * If true, allows invalid UTF-8 binary strings to be converted to JSON strings.
223
- *
224
- * Otherwise, an error will be thrown if encoding a binary string to a JSON cannot be done losslessly.
225
- */
226
- lossyBinaryStringConversion?: boolean;
227
- }
228
- /**
229
- * Encode an Encodable object to a JSON string.
230
- * @param e - The object to encode
231
- * @param options - Optional encoding options. See {@link EncodeJSONOptions} for more information.
232
- * @returns A JSON string encoding of the object
233
- */
234
- declare function encodeJSON(e: Encodable, options?: EncodeJSONOptions): string;
235
- //#endregion
236
- export { ERROR_CONTAINS_EMPTY_STRING, Encodable, EncodableClass, EncodeJSONOptions, JSONEncodingData, MsgpackEncodingData, MsgpackRawStringProvider, PrepareJSONOptions, Schema, decodeJSON, decodeMsgpack, decodeObj, encodeJSON, encodeMsgpack, encodeObj, jsonEncodingDataToMsgpackEncodingData, msgpackEncodingDataToJSONEncodingData, msgpackRawDecode, msgpackRawDecodeAsMap, msgpackRawEncode };
237
- //# sourceMappingURL=encoding.d.ts.map