Skip to content
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 package deploy demo #29

Closed
wants to merge 4 commits into from
Closed

add package deploy demo #29

wants to merge 4 commits into from

Conversation

baichuan3
Copy link

增加生成合约package payload和签名的逻辑,通过交易部署合约

src/utils/tx.ts Outdated
@@ -57,7 +58,7 @@ export function encodePackage(
// Step 1: generate RawUserTransaction
export function generateRawUserTransaction(
senderAddress: HexString,
payload: starcoin_types.TransactionPayload,
payload: starcoin_types.TransactionPayloadVariantPackage,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方的类型不能改,而且不用改也不会报错。

TransactionPayload 同时支持 TransactionPayloadVariantScriptFunction 和 TransactionPayloadVariantPackage
你如果把这个函数的这个类型改了,那么用户要签一个ScriptFunction 就报错了

}
}
]
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要删掉这段注释呢?

@@ -0,0 +1,131 @@
import { JsonRpcProvider } from '.';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/providers/jsonrpc-provider.package.spec.ts 没有必要单独新建这一个文件,
可以在原来的src/providers/jsonrpc-provider.spec.ts
里面加一个test case即可

// Step 1: generate RawUserTransaction
export function generateRawUserTransactionForPackage(
senderAddress: HexString,
payload: starcoin_types.Package,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我的理解,这个地方不需要新建 generateRawUserTransactionForPackage
可以继续使用generateRawUserTransaction
因为 function generateRawUserTransaction
的参数 payload: 的数据类型是 starcoin_types.TransactionPayload

starcoin_types.TransactionPayload 是多态,
你给他传一个 数据类型是TransactionPayloadVariantPackage 或 TransactionPayloadVariantScriptFunction 的payload 都可以

const senderAddressHex = '0x4b2b6e26ee6919d6878c05ae2c3572da';

const moduleAddressHex = '0x4b2b6e26ee6919d6878c05ae2c3572da';
const moduleHex = '0x4b2b6e26ee6919d6878c05ae2c3572da02ab02a11ceb0b0200000009010006020609030f2204310805392807615708b801200ad801050cdd0126000001010102000007000202040100000300010000040201000206040101040107050101040204070801040108090101040203030304030503010c00020c0401080002060c0201060c010b0101080002060c04010b0101090002060c0b0101090003506464074163636f756e7405546f6b656e04696e6974046d696e740b64756d6d795f6669656c640e72656769737465725f746f6b656e0f646f5f6163636570745f746f6b656e0f6465706f7369745f746f5f73656c664b2b6e26ee6919d6878c05ae2c3572da0000000000000000000000000000000100020105010002000001060e00310338000e003801020102000006080e000a0138020c020e000b02380302008d03a11ceb0b020000000a010006020609030f3a04490c0555310786017a0880022006a002030aa302050ca80238000001010102000007000202040100000300010000040102010400050301000006010400020806010104010907010104020a010202040402050a0b0104010b0c010104020601040104040505050608070508050905010c000101020c04010501080002060c0201060c0208000900010b0101080002060c04010b0101090002060c0b0101090003414243074163636f756e7405546f6b656e04696e69740669735f616263046d696e740d746f6b656e5f616464726573730b64756d6d795f6669656c640e72656769737465725f746f6b656e0f646f5f6163636570745f746f6b656e0d69735f73616d655f746f6b656e0f6465706f7369745f746f5f73656c664b2b6e26ee6919d6878c05ae2c3572da0000000000000000000000000000000102011200020107010002000001060e00070038000e003801020101000001023802020202000009080e000a0138030c020e000b023804020301000001023805020000';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能不能在这里加一段注释,说明moduleHex的生成方式,比如命令行的步骤

@jolestar
Copy link
Member

这个是不是可以进一步推进一下了? @muzixinly @wk3368

@wk3368
Copy link
Collaborator

wk3368 commented May 16, 2022

Implemented with mpm in 8866795

@wk3368 wk3368 closed this May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants