Skip to content

Commit

Permalink
added FA2Helper namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
itamarreif committed Jan 3, 2021
1 parent 8c805f2 commit 71c918b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 58 deletions.
63 changes: 54 additions & 9 deletions src/chain/tezos/contracts/tzip12/FA2Helper.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
import {KeyStore, Signer, TezosNodeWriter, TezosParameterFormat} from 'conseiljs';
import {MintPair, MintPairMicheline, BurnPair, BurnPairMicheline, StoragePair, DeployPair} from './FA2Types';
// import {config} from './config';
import {KeyStore, Signer} from '../../../../types/ExternalInterfaces';
import {TezosNodeWriter} from '../../TezosNodeWriter';
import {TezosParameterFormat} from '../../../../types/tezos/TezosChainTypes';

// deploy parameters
export interface DeployPair {
admin: string;
}
// mint
export interface MintPair {
address: string;
amount: number;
sym: string;
token_id: number;
}
// burn
export interface BurnPair {
address: string;
amount: number;
sym: string;
token_id: number;
}
// contract interface
interface FA2Contract {
address: string;
ledgerMapID: number;
}
export namespace FA2Helper {

export interface FA2Contract {
address: string;
ledgerMapID: number;
storage: StoragePair;
}

// need to add interface and micheline func for DeployPair
export async function Deploy(signer: Signer, keystore: KeyStore, config): Promise<string> {
Expand Down Expand Up @@ -63,8 +81,35 @@ export namespace FA2Helper {
TezosParameterFormat.Micheline);
return clearRPCOperationGroupHash(nodeResult.operationGroupID);
}


function DeployPairMicheline(): string {
return ``;
}


export function MintPairMicheline(mint: MintPair): string {
return `{
"prim": "Pair",
"args": [
{ "prim": "Pair", "args": [ { "string": "${mint.address}" }, { "int": "${mint.amount}" } ] },
{ "prim": "Pair", "args": [ { "string": "${mint.sym}" }, { "int": "${mint.token_id}" } ] }
]
}`;
}


export function BurnPairMicheline(burn: BurnPair): string {
return `{
"prim": "Pair",
"args": [ { "string": "${burn.address}" },
{ "prim": "Pair", "args": [ { "int": "${burn.amount}" }, { "int": "${burn.token_id}" } ] }
]
}`;
}
}

function clearRPCOperationGroupHash(hash: string) {
function clearRPCOperationGroupHash(hash: string): string {
return hash.replace(/\"/g, '').replace(/\n/, '');
}

48 changes: 0 additions & 48 deletions src/chain/tezos/contracts/tzip12/FA2Types.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export * from './chain/tezos/contracts/tzip12/ChainlinkTokenHelper';
export * from './chain/tezos/contracts/tzip12/MultiAssetTokenHelper';
export * from './chain/tezos/contracts/tzip12/SingleAssetTokenHelper';
export * from './chain/tezos/contracts/tzip12/FA2Helper';
export * from './chain/tezos/contracts/tzip12/FA2Types';
export * from './chain/tezos/contracts/TzbtcTokenHelper';
export * from './chain/tezos/contracts/WrappedTezosHelper';

Expand Down

0 comments on commit 71c918b

Please sign in to comment.