-
Notifications
You must be signed in to change notification settings - Fork 0
done #36
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
done #36
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ export function CreateMosaicTx({ | |
| networkType = 'testnet', | ||
| senderPrivateKey, | ||
| transferable = true, | ||
| duration = 86400n, | ||
| fee = 1_000_000n, | ||
| deadlineHours = 2 | ||
| }) { | ||
|
|
||
|
|
@@ -16,9 +18,10 @@ export function CreateMosaicTx({ | |
| const privateKey = new PrivateKey(senderPrivateKey.trim()); | ||
| const keyPair = facade.createAccount(privateKey); | ||
|
|
||
| const safeDeadlineHours = Math.min(Math.max(Number(deadlineHours) || 2, 1), 2); | ||
| const deadline = facade.network | ||
| .fromDatetime(new Date()) | ||
| .addHours(Number(deadlineHours)) | ||
| .addHours(safeDeadlineHours) | ||
| .timestamp; | ||
|
Comment on lines
+21
to
25
|
||
|
|
||
| // uint32 nonce | ||
|
|
@@ -40,7 +43,8 @@ export function CreateMosaicTx({ | |
| const mosaicDefinitionTx = facade.transactionFactory.create({ | ||
| type: 'mosaic_definition_transaction_v1', | ||
| signerPublicKey: keyPair.publicKey, | ||
| duration: 0n, | ||
| fee: BigInt(fee), | ||
| duration: BigInt(duration), | ||
| nonce: nonce, | ||
|
Comment on lines
+46
to
48
|
||
| flags: flags, | ||
| divisibility: 0, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,7 +24,8 @@ export default function CreateTransferTx({ | |||||||||||||
| const keyPair = facade.createAccount(privateKeyObject); | ||||||||||||||
|
|
||||||||||||||
| // Deadline 作成 (v3のfromDatetimeはDateオブジェクトを受け取ります) | ||||||||||||||
| const deadline = facade.network.fromDatetime(new Date()).addHours(Number(deadlineHours)).timestamp; | ||||||||||||||
| const safeDeadlineHours = Math.min(Math.max(Number(deadlineHours) || 2, 1), 2); | ||||||||||||||
|
||||||||||||||
| const safeDeadlineHours = Math.min(Math.max(Number(deadlineHours) || 2, 1), 2); | |
| let parsedDeadlineHours = Number(deadlineHours); | |
| if (!Number.isFinite(parsedDeadlineHours) || parsedDeadlineHours === 0) { | |
| parsedDeadlineHours = 2; | |
| } | |
| const safeDeadlineHours = Math.min(Math.max(parsedDeadlineHours, 1), 2); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,44 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { PrivateKey } from 'symbol-sdk'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { SymbolFacade } from 'symbol-sdk/symbol'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { SymbolFacade } from 'symbol-sdk/symbol'; |
Copilot
AI
Feb 21, 2026
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.
waitForConfirmation will abort immediately if fetch(...) throws (e.g., transient network/DNS/TLS error), instead of continuing to poll until timeoutMs. Wrap the polling HTTP calls in a try/catch (or handle non-HTTP failures) so temporary node connectivity issues don’t cause a false failure.
| const confirmedRes = await fetch(`${nodeUrl}/transactions/confirmed/${hash}`); | |
| if (confirmedRes.ok) { | |
| return { confirmed: true }; | |
| } | |
| const statusRes = await fetch(`${nodeUrl}/transactionStatus/${hash}`); | |
| if (statusRes.ok) { | |
| const statusJson = await statusRes.json(); | |
| const code = statusJson?.code; | |
| if (code && code !== 'Success') { | |
| throw new Error(`Transaction rejected: ${code}`); | |
| } | |
| try { | |
| const confirmedRes = await fetch(`${nodeUrl}/transactions/confirmed/${hash}`); | |
| if (confirmedRes.ok) { | |
| return { confirmed: true }; | |
| } | |
| const statusRes = await fetch(`${nodeUrl}/transactionStatus/${hash}`); | |
| if (statusRes.ok) { | |
| const statusJson = await statusRes.json(); | |
| const code = statusJson?.code; | |
| if (code && code !== 'Success') { | |
| throw new Error(`Transaction rejected: ${code}`); | |
| } | |
| } | |
| } catch (error) { | |
| // Network / transport / parsing errors: log and continue polling until timeout | |
| console.warn(`waitForConfirmation: transient error while polling ${hash} at ${nodeUrl}:`, error); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ export const CreateSupplyTx = ({ | |
| senderPrivateKey, | ||
| supply = 1_000_000n, | ||
| mosaicId, | ||
| fee = 1_000_000n, | ||
| deadlineHours = 2 | ||
| }) => { | ||
|
|
||
|
|
@@ -19,6 +20,10 @@ export const CreateSupplyTx = ({ | |
| if (!mosaicId) | ||
| throw new Error("mosaicId is undefined"); | ||
|
|
||
| const supplyDelta = BigInt(supply); | ||
| if (supplyDelta <= 0n) | ||
| throw new Error("supply must be greater than 0"); | ||
|
|
||
| // Facade | ||
| const facade = new SymbolFacade(networkType); | ||
|
|
||
|
|
@@ -27,19 +32,21 @@ export const CreateSupplyTx = ({ | |
| const keyPair = facade.createAccount(privateKey); | ||
|
|
||
| // Deadline | ||
| const safeDeadlineHours = Math.min(Math.max(Number(deadlineHours) || 2, 1), 2); | ||
| const deadline = facade.network | ||
| .fromDatetime(new Date()) | ||
| .addHours(Number(deadlineHours)) | ||
| .addHours(safeDeadlineHours) | ||
| .timestamp; | ||
|
Comment on lines
+35
to
39
|
||
|
|
||
| // ★ ここ重要 | ||
| const supplyTx = facade.transactionFactory.create({ | ||
| type: 'mosaic_supply_change_transaction_v1', | ||
| signerPublicKey: keyPair.publicKey, | ||
| fee: BigInt(fee), | ||
|
|
||
| mosaicId: BigInt('0x' + mosaicId), // 必ずBigInt | ||
| delta: BigInt(supply), // 必ずBigInt | ||
| action: 0, // ★ increaseは0 | ||
| delta: supplyDelta, // 必ずBigInt | ||
| action: 1, // increase は 1 | ||
|
|
||
| deadline | ||
| }); | ||
|
|
||
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.
The default mosaic
durationchanged from effectively unlimited (0n) to86400n. This is a behavior change that will make newly created mosaics expire after a fixed duration by default. If expiration is intended, consider requiring callers to passdurationexplicitly (or at least documenting the units and rationale); otherwise consider keeping the previous default of0n.