Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
NEP-452 Linkdrop Standard #452
NEP-452 Linkdrop Standard #452
Changes from 12 commits
de47911
de454c1
c0d764b
f4df068
54322db
62398fd
7eac04f
f2f0486
8a2b1d7
f52586a
e1b4b18
5877eba
11d006c
e5bf766
8e50122
382d4a8
3968d96
845cd53
2bd6fcd
1bf0268
c61f9fb
07f4da2
ac9a8bd
17c0294
09ee654
d513e1b
75e6e9b
256a24b
f349084
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
How do you see this gas being split between the calls? There are two arrays that require cross-contract calls (
NFTData[]
andFTData[]
), and there is also some gas to be preallocated for the account creation callback and assets transfer callback functions, so there is a lot to unpack here.P.S. It feels that it is quite trivial to end up with a linkdrop that won't have enough gas to transfer all the assets in a single transaction. Thus, one area for future possibilities would be a multi-stage withdrawal.
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.
If not provided, will the gas for each leg of the transaction be deducted from the deposit? I would clarify this behavior in the comments.
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.
I strongly believe that the gas distribution and the inner workings of the logic should not be addressed in this standard. In my eyes, this standard allows anyone to claim a linkdrop regardless of where it originated from (keypom,
near
/testnet
, neardrop etc...). If you have a linkdrop that follows this standard, you will know how to claim it and what to expect.How gas is distributed should be left to the smart contract developer in my opinion.
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.
@BenKurrek Well, this is exactly who I care about, the developers of the smart contract who would be in a tough situation where they only have the total gas allocation, and they need to somehow figure out how to spend it wisely. While alternatively, we might have
required_gas
specified on the FTData / NFTData level. How does Keypom handle it?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.
After a second thought, I agree with this statement. Consider adding a hint to the readers that it is expected that it is the responsibility of a linkdrop contract to define how exactly to calculate the required gas (either automatically on the contract side with linkdrop creation, or even move this responsibility to the client code of linkdrop creation)
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.
I also think that we should not standarize the gas logic here. However we should document the issue here.
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.
Maybe, remove the field at all, is it a so useful field? The user won't be dissatisfied with attaching the 100Tgas by default, or 300TGas in a case of failure.
For instance, what happens if
ft_transfer_call
fails? Nothing bad, the front-end developer specifies more Gas. I also foresee the gas amount is going to be hard-coded (predictable).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.
My preference is to standardize how much gas to attach but leave it to the developers to choose how they distribute that gas throughout the transaction. I can leave a note explaining that it's the developer's responsibility but not force them through a certain flow.
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.
I've added a note under the field. Let me know if this suffices.
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.
Have you considered renaming it to
near_amount
or even introducingNEARData
type to matchFTData
type whereamount
is used?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.
near_amount would make sense here and possibly minimize potential confusion with FT drops
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.
This is a good suggestion although the amount will be in yocto... do you think this would be obvious enough?
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.
Good call, we can go with
yoctonear_amount
thenThere 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.
yNEAR
oryoctoNEAR
,y_near
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.
I like
yoctoNEAR
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.
@BenKurrek I just noticed that you've changed it to
yoctoNEAR
- it's against Rust naming convention, it's better to go withyoctonear
oryoctonear_amount
.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.
I'll do
yoctonear
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.
I copied this directly from the FT standard - do you still wanna change it?
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.
I think the suggestion is more meaningful.
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.
@robert-zaremba I feel both explanations are equally cumbersome 🤷♂️ , so I would leave the original one for now since it is an extract from an existing NEP, and think about how we can improve this situation with stringified numbers universally for all the NEPs going forward.
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.
IMHO, the original is text is not clear. Should be changed. Replicating bad documentation should not be an excuse.
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.
why do we include this in a new standard if it is deprecated? let's remove.
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.
I included it as to be backwards compatible with legacy contracts. If we change it, we're forcing every contract to change if they want to be compatible.
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.
@frol do you have opinions here?
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.
let's better explain it:
Personally I prefer 2.
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.
@BenKurrek I think we should drop the deprecated method from the spec, and migrate wallets to the new method (we should update
get_key_information
in the near-linkdrop to returnyoctoNEAR
and deploy it)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.
seams the spec was not updated, but the comment was resolved. Reopening it.
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.
This does not match the near-linkdrop contract implementation, which returns an empty string result on
claim
since it defers the transaction result to the instantiated TRANSFER receipt. Given that there is not so much value in the boolean (why would you returnfalse
instead of failing the function call?), I think there is no reason to break the compatibility.P.S. On the other hand,
create_account_and_claim
returns a boolean.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.
This is a tricky one... On the Keypom protocol, we do manual bookkeeping of an access key's allowance since this information isn't exposed in the trie. This is so that we can refund the funder for any unspent allowance. This bookkeeping won't work if the transaction fails since the state changes will be reverted.
I'm unsure as to how to proceed..
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.
Well, indeed, it is a tough compatibility issue now. I have a solution, but I cannot say I love it.
You can still return an error without crashing the current receipt - you crash a cross-contract receipt. I.e.
claim
function would update the storage, and initiate a cross-contract call that will crash. It is ugly and requires more gas for the cross-contract call in case of an error, but you should have enough gas to do that as you don't call the transfers and don't call the callback handler.Given there is a misalignment on the near-linkdrop contract between the
claim
andcreate_account_and_claim
calls, I would consider updating theclaim
implementation by adding the callback that will returnboolean
(you will want to reach out to wallets to check if this change affects them)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.
@mattlockyer It seems that you have a strong opinion on maintaining 100% compatibility with the near-linkdrop contract. What do you think about this breaking change?
@BenKurrek Given that panic is always possible (e.g. not enough gas), it is fair to expect that clients must also implement handlers for those (in addition to the boolean value). The problem is that the current clients only implemented the handlers for panics, and not for booleans, but once the standard is published, we can share it with the implementors to update their code.
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.
Isn't the existing contract upgradeable? Do we have a list of products which adopted it? What is the risk of breaking the compatibility now? If it's only a handful and we can easily update them, then breaking the compatibility for having a long term benefits is OK.
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.
What they want to save? Would help to understand the issue
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.
@robert-zaremba There was a message from Ben above: #452 (comment)
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.
@BenKurrek We had a discussion with @frol and @robert-zaremba and we arrived at the following conclusion:
Promise<KeyInfo>
would be a good choice as a return type for bothclaim
andcreate_account_and_claim
methods.panic
, e.g. in the final callback handler after all cross-contract FT transfers.near-linkdrop
backward compatibility as it leads to standardizing an inconsistent API.That said, it's undecided whether the
KeyInfo
would contain a value of one of the following options:KeyInfo
) that would be the same as returning theget_key_information()
value.KeyInfo
which is the opposite case).Both options have cons and pros. From the client side, it is important to display to the users what they got instead of what they did not get with a free linkdrop. Yet, we can see the argument for returning the "remaining" assets: it's easier to implement, also, combined with the result of a prior call to
get_key_information
, a client can figure out which assets were transferred.We would love to hear your perspective on that. ☝
Finally, let me clarify our reasoning for not considering
bool
andvoid
as a return type:bool
is not extendable, and it's hard to reason the meaning of "true": did it succeed to claim, or did it allow to claim, what's the actual status of transfers, etc.?void
doesn't get benefits compared toKeyInfo
, the latter reveals the status of the claim, also potentially saving additional RPC calls.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.
BTW, I still think we should consider advocating a
Result<_,_>
type (of the last receipt) which will not triggerpanic
, but may signal transaction failure.Panics / reverts are kind of a standard in the Ethereum synchronous execution model, but I think we should do more research about pros/cons for such approach.
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.
After further discussion, I propose to keep things simple and keep
boolean
as the return value ofclaim
andcreate_account_and_claim
functions. Here is my reasoning:claim
method are rare as usually dApps check if the claim is still available before submitting the transactionboolean
return value forclaim
aligns it with thecreate_account_and_claim
, which usesboolean
as its return value since day oneThis was the only remaining concern blocking this NEP, and @fadeevab @abacabadabacaba agreed that we don't need to block it any longer.
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.
I think it is worth linking to a specific commit state as who knows how the implementations will evolve in the future.
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.
I haven't implemented this specific standard as it's not finalized but once we finish with the interface, I'll make a PR into keypom and then link the commit here.