-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add typing to polkadot queries and events #1001
base: develop
Are you sure you want to change the base?
Conversation
async function getSubIdentityName(helper: UniqueHelper, address: string) { | ||
return ((await helper.getApi().query.identity.superOf(address)).toHuman() as any); | ||
function instanceOfCodec(obj: any): obj is Codec { | ||
return typeof obj == 'object' && 'registry' in obj; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obj instanceof Codec, не?
} | ||
|
||
describe('Integration Test: Identities Manipulation', () => { | ||
let superuser: IKeyringPair; | ||
|
||
before(async function() { | ||
if(!process.env.RUN_COLLATOR_TESTS) this.skip(); | ||
function equal(this: any, _super: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Неплохо, но надо бы это для всех тестов включить (глобальный before/вообще без обёрток)
tests/package.json
Outdated
@@ -140,6 +140,7 @@ | |||
"@polkadot/wasm-crypto-wasm": "^7.2.1", | |||
"@rmrk-team/evm-contracts": "^1.2.1", | |||
"@typechain/web3-v1": "^6.0.3", | |||
"@unique-nft": "workspaces^", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"@unique-nft": "workspaces^", | |
"@unique-nft/opal-testnet-types": "workspaces^", |
@@ -152,6 +153,9 @@ | |||
"resolutions": { | |||
"decode-uri-component": "^0.2.1" | |||
}, | |||
"workspaces": [ | |||
"src/interfaces" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В интерфейсы нужно добавить package.json с name: @unique-nft/opal-testnet-types
1f54fc9
to
625bc84
Compare
@@ -123,7 +123,7 @@ describe('Integration Test: Identities Manipulation', () => { | |||
const oldIdentities = await getIdentityAccounts(helper); | |||
|
|||
// delete a couple, check that they are no longer there | |||
const registry = helper.api!.registry; | |||
const registry = helper.getApi().registry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему бы не переименовать поле api в _api/#api, и не создать getter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В плане,
#api?: ApiPromise;
get api(): ApiPromise {
if(this.#api) return this.#api;
this.#api = ApiPromise.create(...);
return this.#api;
}
Чтобы не писать везде getApi(), это некрасиво)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Там в текущей реализации бросает эксцепшен, если коннекта нет, это как раз то поведение, которое хочется сохранить. Через геттеры вроде не очень эксцепшенами бросаться
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Какая разница, эксепшон оно кинет, или руганётся на undefined в случае с .api!
У нас коннекшон есть в 99% случаев, я не думаю что ради этого стоит весь код в таком стиле писать
Из геттеров можно бросаться эксепшонами, в стектрейсе они тоже видны
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У нас - да, однако в скриптах хелпер инициализируется самостоятельно, без using.
Это оттуда пошло и опять же хочу сохранить для пакета.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Потом в скриптах у меня было часто
const api = helper.getApi();
Что не так красиво, обращаясь к его свойству
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну вот да, с get методом напрашивается сделать один раз получение
А если геттером сделать - то можно код как есть оставить
6d7420f
to
742522c
Compare
No description provided.