Skip to content

Commit

Permalink
Add @Privatemethod decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
sidenaio committed Feb 28, 2023
1 parent 18c5d58 commit 4f1dccd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions bindgen/assembly/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSONEncoder as _JSONEncoder, JSON } from "idena-assemblyscript-json";
import { Bytes, env, u256, storage, util, u128, allocate, Address, base64, debug, Balance} from 'idena-sdk-core';
import { Bytes, env, u256, storage, util, u128, allocate, Address, base64, debug, Balance, Context} from 'idena-sdk-core';
// Runtime functions
// tslint:disable: no-unsafe-any
/* eslint-disable @typescript-eslint/no-unused-vars */
Expand Down Expand Up @@ -682,10 +682,9 @@ class Result<T> {
}


/*

@global
function __assertPrivate(): void {
let contractName = Context.contractName;
assert(contractName == Context.predecessor, `Only ${contractName} can call this method.`);
let addr = Context.contractAddress();
assert(addr == Context.caller(), `Only ${addr.toHex()} can call this method.`);
}
*/
4 changes: 2 additions & 2 deletions bindgen/dist/classExporter.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindgen/src/classExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {isEntry} from './JSONBuilder';
import {SimpleParser} from './utils';

const toString = utils.toString;
const privateDecorator = 'contractPrivate';
const privateDecorator = 'privateMethod';

export class ClassExporter extends ClassDecorator {
sb: string[] = [];
Expand Down
4 changes: 2 additions & 2 deletions sdk-core/assembly/as_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ declare interface Uint8Array {
/**
*
* Asserts that a contract method is private, e.i.
* Context.contractName == Context.predecessor
* Context.contractAddress() == Context.caller()
*/
declare function contractPrivate(): (target: any,
declare function privateMethod(): (target: any,
propertyKey: string,
descriptor: any) => void;

0 comments on commit 4f1dccd

Please sign in to comment.