Skip to content

Commit

Permalink
chore: renamed EOSIO_CORE variables
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Aug 25, 2023
1 parent aa0af60 commit 7c0c642
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/codegen/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/data/abis/eosio.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"type": "uint16"
}
]
},
}
],
"variants": [
{
Expand Down
22 changes: 11 additions & 11 deletions test/tests/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down Expand Up @@ -124,6 +124,6 @@ suite('codegen', async function () {
}
})
teardown(() => {
removeCodegenContracts()
// removeCodegenContracts()
})
})
41 changes: 41 additions & 0 deletions test/tmp/eosio.ts
Original file line number Diff line number Diff line change
@@ -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<ContractArgs, 'abi' | 'account'>) {
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
2 changes: 2 additions & 0 deletions test/utils/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c0c642

Please sign in to comment.