forked from Joystream/hydra
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typegen): tuple return type for event.params (Joystream#358)
* feat(hydra-typegen): use tuple-based return type for event parameters (vs type-based names) affects: @dzlzv/hydra-typegen * fix(hydra-cli): update mappings for new typegen event parameters format affects: @dzlzv/hydra-cli, @dzlzv/hydra-typegen, sample, sample-mappings
- Loading branch information
Showing
10 changed files
with
185 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
import { expect } from 'chai' | ||
import { nameFromType } from '.' | ||
import { helper } from './helpers' | ||
import { compact as c } from '../util' | ||
|
||
describe('helpers', () => { | ||
it('should name from arg type', () => { | ||
expect(nameFromType('Compact<Balance> & Codec')).to.equal('balance') | ||
expect(nameFromType('MyLongType & Codec')).to.equal('myLongType') | ||
expect(nameFromType('SimpleType')).to.equal('simpleType') | ||
it('should render return type ', () => { | ||
const prmsReturn = helper.paramsReturnType.bind({ | ||
args: ['Type1', 'Type2 & Codec', 'Option<Type3>'], | ||
}) | ||
expect(c(prmsReturn())).to.equal(c(`[Type1, Type2 & Codec, Option<Type3>]`)) | ||
}) | ||
|
||
it('should render return type statement', () => { | ||
const prmsReturnStmt = helper.paramsReturnStmt.bind({ | ||
args: ['Type1', 'Type2 & Balance'], | ||
}) | ||
expect(c(prmsReturnStmt())).to.equal( | ||
c(`return [createTypeUnsafe<Type1 & Codec>( | ||
typeRegistry, 'Type1', [this.ctx.params[0].value]), | ||
createTypeUnsafe<Type2 & Balance & Codec>( | ||
typeRegistry, 'Type2 & Balance', [this.ctx.params[1].value])]`) | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.