-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update management canister interface with latest bitcoin featu…
…res (#890) * chore: update management canister interface with latest bitcoin features * updating actor and management_service * feat: automation to update the management canister IDL * cleaning up ts errors
- Loading branch information
Showing
9 changed files
with
347 additions
and
243 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { $, cd, fetch } from 'zx'; | ||
import path from 'path'; | ||
|
||
fetch( | ||
'https://raw.githubusercontent.com/dfinity/interface-spec/master/spec/_attachments/ic.did', | ||
).then(async res => { | ||
res.text().then(async text => { | ||
const root = path.resolve(__dirname, '..'); | ||
|
||
const candid = text; | ||
|
||
await cd(`${root}/packages/agent/src/canisters`); | ||
|
||
await $`echo ${candid} > management.did`; | ||
let ts = (await $`didc bind management.did -t ts`).toString(); | ||
let js = (await $`didc bind management.did -t js`).toString(); | ||
|
||
const didcVersion = await $`didc --version`; | ||
|
||
const prefix = `/* | ||
* This file is generated from the candid for asset management. | ||
* didc version: ${didcVersion.toString().split(' ')[1].trim()} | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
`; | ||
|
||
// replace first line of service | ||
|
||
ts = ts.replace(`export interface _SERVICE {`, `export default interface _SERVICE {`); | ||
js = js.replace(`export const idlFactory = ({ IDL }) => {`, `export default ({ IDL }) => {`); | ||
|
||
// remove init function | ||
js = js.split('export const init = ({ IDL }) => {')[0]; | ||
|
||
ts = prefix + ts; | ||
js = prefix + js; | ||
|
||
await $`echo ${js} > management_idl.ts`; | ||
await $`echo ${ts} > management_service.ts`; | ||
|
||
await cd(`${root}`); | ||
|
||
await $`npm run prettier:format`; | ||
|
||
console.log('Done!'); | ||
}); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.