Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'aptos'
  • Loading branch information
wk3368 committed Oct 6, 2022
2 parents 7ca36cc + d0aa3c3 commit 884b802
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file, as of versi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.0] - 2022-10-06

- Support Aptos which address length is 64, while starcoin address length is 32
- Fix: Replace halley chainId from 3 to 253

## [2.1.6] - 2022-06-07

- Fix: TypeError: Buffer.from(...).readBigUInt64LE is not a function in browsers, [https://github.com/starcoinorg/starcoin.js/issues/54](https://github.com/starcoinorg/starcoin.js/issues/54)
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@starcoin/starcoin",
"version": "2.1.6",
"version": "2.2.0",
"description": "starcoin js sdk",
"author": "lerencao, wk3368, tarvos21",
"license": "Apache-2.0",
Expand Down
23 changes: 12 additions & 11 deletions src/providers/formatter.ts
Expand Up @@ -98,7 +98,7 @@ export function formatMoveValue(v: AnnotatedMoveValue): MoveValue {
{}
);
}
throw new Error(`invalid annotated move value, ${JSON.stringify(v)}`);
throw new Error(`invalid annotated move value, ${ JSON.stringify(v) }`);

}

Expand Down Expand Up @@ -309,7 +309,7 @@ export class Formatter {
return value as TransactionVMStatus;
}

throw new Error(`invalid txn vm_status: ${value}`);
throw new Error(`invalid txn vm_status: ${ value }`);
} else if (typeof value === 'object') {
if (value.MoveAbort) {
return {
Expand All @@ -329,9 +329,9 @@ export class Formatter {
}
};
}
throw new Error(`invalid txn vm_status: ${JSON.stringify(value)}`);
throw new Error(`invalid txn vm_status: ${ JSON.stringify(value) }`);
} else {
throw new TypeError(`invalid txn vm_status type ${value}`);
throw new TypeError(`invalid txn vm_status type ${ value }`);
}
}

Expand All @@ -350,7 +350,7 @@ export class Formatter {
} if (typeof value === 'number') {
return value;
}
throw new Error(`invalid u8: ${value}`);
throw new Error(`invalid u8: ${ value }`);
}

u64(number: any): U64 {
Expand All @@ -368,7 +368,7 @@ export class Formatter {
if (typeof number === 'number') {
return number.toString();
}
throw new Error(`invalid bigint: ${number}`);
throw new Error(`invalid bigint: ${ number }`);
}

static bigint(number: any): number | bigint {
Expand All @@ -384,7 +384,7 @@ export class Formatter {
if (typeof number === 'number') {
return number;
}
throw new TypeError(`invalid bigint: ${number}`);
throw new TypeError(`invalid bigint: ${ number }`);
}

// Strict! Used on input.
Expand All @@ -406,13 +406,13 @@ export class Formatter {
return false;
}
}
throw new Error(`invalid boolean - ${value}`);
throw new Error(`invalid boolean - ${ value }`);
}

hex(value: any, strict?: boolean): string {
if (typeof value === 'string') {
if (!strict && value.slice(0, 2) !== '0x') {
value = `0x${value}`;
value = `0x${ value }`;
}
if (isHexString(value)) {
return value.toLowerCase();
Expand All @@ -424,7 +424,7 @@ export class Formatter {
data(value: any, strict?: boolean): string {
const result = this.hex(value, strict);
if (result.length % 2 !== 0) {
throw new Error(`invalid data; odd-length - ${value}`);
throw new Error(`invalid data; odd-length - ${ value }`);
}
return result;
}
Expand All @@ -436,7 +436,8 @@ export class Formatter {
logger.throwArgumentError('invalid address', 'address', value);
}
const result = this.hex(value, true);
if (hexDataLength(result) !== 16) {
const length = hexDataLength(result)
if (length !== 16 && length !== 32) {
return logger.throwArgumentError('invalid address', 'value', value);
}
return addHexPrefix(value);
Expand Down

0 comments on commit 884b802

Please sign in to comment.