Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
tolya-yanot committed Mar 22, 2022
1 parent 7599542 commit f330415
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Each part is documented separately:
```bash
npm install

npx webpack --mode=none
npm run build
```

## Use as alternative to Fift for building binary messages to smart-contracts
Expand Down
2 changes: 1 addition & 1 deletion dist/tonweb.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/boc/BitString.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ class BitString {
}

/**
* Represents the specified multibyte string as bytes and writes
* them to the bit-string, starting at the current index and
* advances the current index cursor by the number of bits written.
* Write UTF-8 string
*
* @param value {string}
*/
Expand Down
6 changes: 4 additions & 2 deletions src/contract/wallet/WalletContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ class WalletContract extends Contract {
if (payload.refs) { // is Cell
payloadCell = payload;
} else if (typeof payload === 'string') {
payloadCell.bits.writeUint(0, 32);
payloadCell.bits.writeString(payload);
if (payload.length > 0) {
payloadCell.bits.writeUint(0, 32);
payloadCell.bits.writeString(payload);
}
} else {
payloadCell.bits.writeBytes(payload)
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/HttpProviderUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class HttpProviderUtils {

static parseResponse(result) {
if (result.exit_code !== 0) {
const err = new Error('parse response error')
const err = new Error('http provider parse response error')
err.result = result
throw err
}
Expand Down
9 changes: 1 addition & 8 deletions src/utils/Address.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ const test_flag = 0x80;
* @return {{isTestOnly: boolean, workchain: number, hashPart: Uint8Array, isBounceable: boolean}}
*/
function parseFriendlyAddress(addressString) {
// This check is important, because base64 decoding
// process could ignore one extra character at the
// end of string and the byte-length check below
// won't be able to catch it.
if (addressString.length !== 48) {
throw new Error(
`User-friendly address should contain ` +
`strictly 48 characters`
);
throw new Error(`User-friendly address should contain strictly 48 characters`);
}
const data = stringToBytes(base64toString(addressString));
if (data.length !== 36) { // 1byte tag + 1byte workchain + 32 bytes hash + 2 byte crc
Expand Down
1 change: 1 addition & 0 deletions src/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ function bytesToBase64(bytes) {
return result;
}

// todo: base64 decoding process could ignore one extra character at the end of string and the byte-length check below won't be able to catch it.
function base64toString(base64) {
if (typeof self === 'undefined') {
return Buffer.from(base64, 'base64').toString('binary'); // todo: (tolya-yanot) Buffer silently ignore incorrect base64 symbols, we need to throw error
Expand Down

0 comments on commit f330415

Please sign in to comment.