-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix(PE-7344): update handlers to integrate with token spec #59
Conversation
fb07989
to
0d96d3a
Compare
src/common/main.lua
Outdated
Balance = tostring(balRes), | ||
Ticker = Ticker, | ||
Account = addressToCheck, | ||
Address = addressToCheck, |
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.
left in for backwards compatibility
assert.strictEqual(typeof balanceData, 'string'); | ||
assert.strictEqual(typeof balanceTag, 'string'); | ||
assert.strictEqual(balanceData, balanceTag); | ||
assert.strictEqual(Number.isInteger(parseInt(balanceData)), true); |
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.
Specific to ANTs - in the case of other tokens these would need to be modified to bint checking
)?.value; | ||
assert(errorRef, 'Error notice is not a reply message'); | ||
const errorTag = errorMessage.Tags.find((t) => t.name === 'Error'); | ||
assert.strictEqual(errorTag.value, 'Insufficient Balance!'); |
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.
Since this is mainly for integration with other platforms i wasn't certain on how granular to go here, so decided on exact error messages being enforced.
src/common/main.lua
Outdated
if msg.reply then | ||
msg.reply({ | ||
Action = "Transfer-Error", | ||
["Message-Id"] = msg.Id, | ||
Error = "Insufficient Balance!", | ||
}) | ||
else | ||
ao.send({ | ||
Target = msg.From, | ||
Action = "Transfer-Error", | ||
["Message-Id"] = msg.Id, | ||
Error = "Insufficient Balance!", | ||
}) |
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.
nit - wrap these in a Send util like so https://github.com/ar-io/ar-io-network-process/blob/develop/src/main.lua#L128-L135
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.
makes sense 79bd001
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.
Wrap the msg.reply or ao.send and avoid using it everywhere
Updates handlers to match responses on like handlers from https://github.com/permaweb/aos/blob/main/blueprints/token.lua
Adds a new test specifically for this spec, apart from our existing balances test