diff --git a/src/codegen/helpers.ts b/src/codegen/helpers.ts index d58ebdf..d9b4d97 100644 --- a/src/codegen/helpers.ts +++ b/src/codegen/helpers.ts @@ -4,14 +4,14 @@ import * as ts from 'typescript' import {capitalize} from '../utils' -const EOSIO_CORE_CLASSES: string[] = [] +const ANTELOPE_CLASSES: string[] = [] Object.keys(Antelope).map((key) => { if (Antelope[key].abiName) { - EOSIO_CORE_CLASSES.push(key) + ANTELOPE_CLASSES.push(key) } }) -export const EOSIO_CORE_TYPES = [ +export const ANTELOPE_TYPES = [ 'AssetType', 'BlobType', 'BlockIdType', @@ -141,7 +141,7 @@ export function generateInterface( } export function findCoreClass(type: string): string | undefined { - for (const coreType of EOSIO_CORE_CLASSES) { + for (const coreType of ANTELOPE_CLASSES) { if (type.split('_').join('') === coreType.toLowerCase()) { return coreType } diff --git a/test/data/abis/eosio.json b/test/data/abis/eosio.json index 74e8d2d..a2961ef 100644 --- a/test/data/abis/eosio.json +++ b/test/data/abis/eosio.json @@ -42,7 +42,7 @@ "type": "uint16" } ] - }, + } ], "variants": [ { diff --git a/test/tests/codegen.ts b/test/tests/codegen.ts index 75a6d38..d583e9f 100644 --- a/test/tests/codegen.ts +++ b/test/tests/codegen.ts @@ -4,10 +4,10 @@ import {assert} from 'chai' import fs from 'fs' import {Contract} from 'src/contract' -// import Eosio from '$test/data/contracts/mock-eosio' +import Eosio from '$test/data/contracts/mock-eosio' import EosioToken from '$test/data/contracts/mock-eosio.token' import RewardsGm from '$test/data/contracts/mock-rewards.gm' -// import EosioMsig from '$test/data/contracts/mock-eosio.msig' +import EosioMsig from '$test/data/contracts/mock-eosio.msig' import {generateCodegenContract, removeCodegenContracts} from '$test/utils/codegen' import {runGenericContractTests} from './generic' @@ -22,14 +22,14 @@ interface Code { suite('codegen', async function () { // Contract instances const contracts = { - // eosio: { - // mock: Eosio, - // generated: null, - // }, - // 'eosio.msig': { - // mock: EosioMsig, - // generated: null, - // }, + eosio: { + mock: Eosio, + generated: null, + }, + 'eosio.msig': { + mock: EosioMsig, + generated: null, + }, 'eosio.token': { mock: EosioToken, generated: null, @@ -124,6 +124,6 @@ suite('codegen', async function () { } }) teardown(() => { - removeCodegenContracts() + // removeCodegenContracts() }) }) diff --git a/test/tmp/eosio.ts b/test/tmp/eosio.ts new file mode 100644 index 0000000..7482f08 --- /dev/null +++ b/test/tmp/eosio.ts @@ -0,0 +1,41 @@ +import {ABI, Blob, Name, Struct, UInt16, UInt32} from '@wharfkit/antelope' +import {Contract as BaseContract, ContractArgs, PartialBy} from '../../src/index' +export namespace Eosio { + export const abiBlob = Blob.from( + 'DmVvc2lvOjphYmkvMS4yARdibG9ja19zaWduaW5nX2F1dGhvcml0eSJ2YXJpYW50X2Jsb2NrX3NpZ25pbmdfYXV0aG9yaXR5X3YwAhpibG9ja19zaWduaW5nX2F1dGhvcml0eV92MAACCXRocmVzaG9sZAZ1aW50MzIEa2V5cwxrZXlfd2VpZ2h0W10McmVncHJvZHVjZXIyAAQIcHJvZHVjZXIEbmFtZRJwcm9kdWNlcl9hdXRob3JpdHkXYmxvY2tfc2lnbmluZ19hdXRob3JpdHkDdXJsBnN0cmluZwhsb2NhdGlvbgZ1aW50MTYAAAAAAAEidmFyaWFudF9ibG9ja19zaWduaW5nX2F1dGhvcml0eV92MAEaYmxvY2tfc2lnbmluZ19hdXRob3JpdHlfdjA=' + ) + export const abi = ABI.from(abiBlob) + export class Contract extends BaseContract { + constructor(args: PartialBy) { + super({ + client: args.client, + abi: abi, + account: Name.from('eosio'), + }) + } + } + export interface ActionNameParams {} + export namespace ActionParams {} + export namespace Types { + @Struct.type('block_signing_authority_v0') + export class BlockSigningAuthorityV0 extends Struct { + @Struct.field(UInt32) + threshold!: UInt32 + @Struct.field(KeyWeight, {array: true}) + keys!: KeyWeight[] + } + @Struct.type('regproducer2') + export class Regproducer2 extends Struct { + @Struct.field(Name) + producer!: Name + @Struct.field(Block_signing_authority) + producer_authority!: Block_signing_authority + @Struct.field('string') + url!: string + @Struct.field(UInt16) + location!: UInt16 + } + } + const TableMap = {} +} +export default Eosio diff --git a/test/utils/codegen.ts b/test/utils/codegen.ts index 3b21715..1670e1c 100644 --- a/test/utils/codegen.ts +++ b/test/utils/codegen.ts @@ -5,7 +5,9 @@ import {codegen} from '../../src/codegen' export async function generateCodegenContract(contractName: string) { // Read the ABI from a JSON file + console.log({contractName, path: `test/data/abis/${contractName}.json` }) const abiJson = fs.readFileSync(`test/data/abis/${contractName}.json`, {encoding: 'utf8'}) + console.log({abiJson}) const abi = new ABI(JSON.parse(abiJson)) // Generate the code