Skip to content

Commit

Permalink
writeInt, writeUint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rise1507 committed Jul 31, 2023
1 parent 6c1b8cb commit 448ac6f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/tonweb.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/boc/BitString.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class BitString {
* @param bitLength {number} size of uint in bits
*/
writeUint(number, bitLength) {
if (isNaN(number)) throw new Error('writeUint: value is NaN');
if (number === null) throw new Error('writeUint: value is null');
if (number === undefined) throw new Error('writeUint: value is undefined');
if (!bitLength) throw new Error('writeUint: no bitLength');

number = new BN(number);
if (
bitLength == 0 ||
Expand All @@ -135,6 +140,11 @@ class BitString {
* @param bitLength {number} size of int in bits
*/
writeInt(number, bitLength) {
if (isNaN(number)) throw new Error('writeInt: value is NaN');
if (number === null) throw new Error('writeInt: value is null');
if (number === undefined) throw new Error('writeInt: value is undefined');
if (!bitLength) throw new Error('writeInt: no bitLength');

number = new BN(number);
if (bitLength == 1) {
if (number == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/contract/wallet/WalletContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WalletContract extends Contract {

this.methods = {
/**
* @param params {{secretKey: Uint8Array, toAddress: Address | string, amount: BN | number, seqno: number, payload: string | Uint8Array | Cell, sendMode: number, stateInit?: Cell, expireAt?: number}}
* @param params {{secretKey: Uint8Array, seqno: number, expireAt?: number, toAddress: Address | string, amount: BN, payload?: string | Uint8Array | Cell, sendMode?: number, stateInit?: Cell }}
*/
transfer: (params) => Contract.createMethod(provider, this.createTransferMessage(params.secretKey, params.toAddress, params.amount, params.seqno, params.payload, params.sendMode, !Boolean(params.secretKey), params.stateInit, params.expireAt)),

Expand Down Expand Up @@ -221,7 +221,7 @@ class WalletContract extends Contract {
if (messages.length < 1 || messages.length > 4) {
throw new Error('put 1-4 messages');
}
for (let msg of messages) {
for (const msg of messages) {
let sendMode = msg.sendMode;

This comment has been minimized.

Copy link
@Ebi124567890

This comment has been minimized.

Copy link
@Ebi124567890
if (sendMode === null || sendMode === undefined) {
sendMode = 3;
Expand Down

2 comments on commit 448ac6f

@Mahya0933
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ggg

@Mahya0933
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/contract/wallet/WalletSources.md

Please sign in to comment.