Skip to content

Commit

Permalink
Merge pull request #1 from ton-org/main
Browse files Browse the repository at this point in the history
21
  • Loading branch information
18211308 authored Sep 28, 2024
2 parents 3a68441 + 9c1b8f7 commit 7ff8a05
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
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).

## [0.58.1] - 2024-09-13

## Fixed
- Contract proxy method discovery

## [0.58.0] - 2024-09-13

## Added
- Methods, prefixed with "is" in the contract classes are now wrapped like "send"/"get"

## [0.57.0] - 2024-08-16
## Added
- More flexible merkle proof generation (thx @akifoq)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ton/core",
"version": "0.57.0",
"version": "0.58.1",
"main": "dist/index.js",
"repository": "https://github.com/ton-org/ton-core.git",
"author": "Whales Corp. <developers@whalescorp.com>",
Expand Down
14 changes: 13 additions & 1 deletion src/boc/Cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Cell {
}

/**
* Helper class that deserializes a single cell from BOC in base64
* Helper function that deserializes a single cell from BOC in base64
* @param src source string
*/
static fromBase64(src: string): Cell {
Expand All @@ -45,6 +45,18 @@ export class Cell {
return parsed[0];
}

/**
* Helper function that deserializes a single cell from BOC in hex
* @param src source string
*/
static fromHex(src: string): Cell {
let parsed = Cell.fromBoc(Buffer.from(src, 'hex'));
if (parsed.length !== 1) {
throw new Error("Deserialized more than one cell");
}
return parsed[0];
}

// Public properties
readonly type: CellType;
readonly bits: BitString;
Expand Down
5 changes: 5 additions & 0 deletions src/boc/cell/serialization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,10 @@ describe('boc', () => {
expect(cell.toString()).toBe('x{000000E4}\n x{00000539}\n x{0000053A}');
expect(serialized).toBe('b5ee9c7281010301001400080e140208000000e4010200080000053900080000053a');
});

it('should deserialize cell from hex', () => {
let cell = Cell.fromHex('b5ee9c7241010201000d00010800000001010008000000027d4b3cf8');
expect(cell.toString()).toBe('x{00000001}\n x{00000002}');
});
});

6 changes: 2 additions & 4 deletions src/contract/openContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

import { Address } from "../address/Address";
import { Cell } from "../boc/Cell";
import { Dictionary } from "../dict/Dictionary";
import { StateInit } from "../types/StateInit";
import { Contract } from "./Contract";
import { ContractProvider } from "./ContractProvider";
import { SimpleLibrary } from "../types/SimpleLibrary";

export type OpenedContract<F> = {
[P in keyof F]: P extends `${'get' | 'send'}${string}`
[P in keyof F]: P extends `${'get' | 'send' | 'is'}${string}`
? (F[P] extends (x: ContractProvider, ...args: infer P) => infer R ? (...args: P) => R : never)
: F[P];
}
Expand Down Expand Up @@ -47,7 +45,7 @@ export function openContract<T extends Contract>(src: T, factory: (params: { add
return new Proxy<any>(src as any, {
get(target, prop) {
const value = target[prop];
if (typeof prop === 'string' && (prop.startsWith('get') || prop.startsWith('send'))) {
if (typeof prop === 'string' && (prop.startsWith('get') || prop.startsWith('send') || prop.startsWith('is'))) {
if (typeof value === 'function') {
return (...args: any[]) => value.apply(target, [executor, ...args]);
}
Expand Down

0 comments on commit 7ff8a05

Please # to comment.