@streamflow/stream 5.9.3 → 5.9.5

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.
@@ -18,6 +18,7 @@ exports.Contract = void 0;
18
18
  var bn_js_1 = __importDefault(require("bn.js"));
19
19
  var contractUtils_1 = require("../common/contractUtils");
20
20
  var utils_1 = require("../common/utils");
21
+ var utils_2 = require("./utils");
21
22
  var Contract = /** @class */ (function () {
22
23
  function Contract(stream, tokenId) {
23
24
  this.magic = 0;
@@ -27,10 +28,10 @@ var Contract = /** @class */ (function () {
27
28
  this.canceledAt = parseInt(stream.canceled_at);
28
29
  this.end = parseInt(stream.end);
29
30
  this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
30
- this.sender = stream.sender;
31
- this.senderTokens = stream.sender;
32
- this.recipient = stream.recipient;
33
- this.recipientTokens = stream.recipient;
31
+ this.sender = (0, utils_2.normalizeAptosAddress)(stream.sender);
32
+ this.senderTokens = (0, utils_2.normalizeAptosAddress)(stream.sender);
33
+ this.recipient = (0, utils_2.normalizeAptosAddress)(stream.recipient);
34
+ this.recipientTokens = (0, utils_2.normalizeAptosAddress)(stream.recipient);
34
35
  this.mint = tokenId;
35
36
  this.escrowTokens = "";
36
37
  this.streamflowTreasury = "";
@@ -1 +1,7 @@
1
1
  export declare function extractAptosErrorCode(errorText: string): string | null;
2
+ /**
3
+ * Aptos has inconsistencies in how it returns addresses.
4
+ * This method normalizes them to be 64 characters long, or leaves it as SPECIAL ADDRESS (0x0 - 0xf inclusive)
5
+ * Per this: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/src/core/accountAddress.ts#L115
6
+ * */
7
+ export declare function normalizeAptosAddress(address: string): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractAptosErrorCode = void 0;
3
+ exports.normalizeAptosAddress = exports.extractAptosErrorCode = void 0;
4
4
  var constants_1 = require("./constants");
5
5
  function extractAptosErrorCode(errorText) {
6
6
  var match = constants_1.APTOS_ERROR_MATCH_REGEX.exec(errorText);
@@ -10,3 +10,26 @@ function extractAptosErrorCode(errorText) {
10
10
  return match[2];
11
11
  }
12
12
  exports.extractAptosErrorCode = extractAptosErrorCode;
13
+ function isAddressSpecial(address) {
14
+ if (address.length === 3) {
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+ /**
20
+ * Aptos has inconsistencies in how it returns addresses.
21
+ * This method normalizes them to be 64 characters long, or leaves it as SPECIAL ADDRESS (0x0 - 0xf inclusive)
22
+ * Per this: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/src/core/accountAddress.ts#L115
23
+ * */
24
+ function normalizeAptosAddress(address) {
25
+ if (isAddressSpecial(address)) {
26
+ return address;
27
+ }
28
+ var length = address.length;
29
+ if (length === 64) {
30
+ return address;
31
+ }
32
+ var missingZeros = 64 - length;
33
+ return address.slice(0, 2) + "0".repeat(missingZeros) + address.slice(2);
34
+ }
35
+ exports.normalizeAptosAddress = normalizeAptosAddress;
@@ -20,3 +20,4 @@ export declare const getNumberFromBN: (value: BN, decimals: number) => number;
20
20
  * @returns {T}
21
21
  */
22
22
  export declare function handleContractError<T>(func: () => Promise<T>, callback?: (err: Error) => string | null): Promise<T>;
23
+ export { normalizeAptosAddress } from "../aptos/utils";
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.handleContractError = exports.getNumberFromBN = exports.getBN = void 0;
42
+ exports.normalizeAptosAddress = exports.handleContractError = exports.getNumberFromBN = exports.getBN = void 0;
43
43
  var bn_js_1 = __importDefault(require("bn.js"));
44
44
  var types_1 = require("./types");
45
45
  /**
@@ -99,3 +99,5 @@ function handleContractError(func, callback) {
99
99
  });
100
100
  }
101
101
  exports.handleContractError = handleContractError;
102
+ var utils_1 = require("../aptos/utils");
103
+ Object.defineProperty(exports, "normalizeAptosAddress", { enumerable: true, get: function () { return utils_1.normalizeAptosAddress; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "5.9.3",
3
+ "version": "5.9.5",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
@@ -11,7 +11,7 @@
11
11
  "lint": "eslint .",
12
12
  "prepublishOnly": "npm run lint && npm test && npm run build"
13
13
  },
14
- "gitHead": "bbd68ea8fa88b935fdee2aca406add9bcb584a2d",
14
+ "gitHead": "46440fa057d1544b07c6b06c631344b84ed563a0",
15
15
  "devDependencies": {
16
16
  "@types/bn.js": "5.1.1",
17
17
  "@types/ethereum-checksum-address": "^0.0.0",