This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Using Table. #516
Milestone
Comments
Post a github repo link rather than .tar.gz |
I think your problem was caused by the following code in Win method:
requireNotice( name );
requireAuth( name );
Remove the above code and have another try, that shall work.
mydice.cpp
void Gameplay(const mydice::Game& game) {
player::Win(game.one);
}
Player.hpp
void Win( AccountName name ) {
requireNotice( name );
requireAuth( name );
auto var = getAccount( name );
var.win += 1;
player::Store( var );
// player::Update( var );
}
… On 28 Sep 2017, at 10:23 PM, Antonio ***@***.***> wrote:
I have two contracts.
First - player -( this is contract, creates table and init variable "name" and win = 0.
Second contract -mydice- must change variables in table accounts which contain variables.
The contract player can change itself. But contract number two can not change table in accounts.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#516>, or mute the thread <https://github.com/notifications/unsubscribe-auth/Ad6ZPhNIZgb95ptlgak3FY80GtLXqtLnks5sm6vagaJpZM4PnWRt>.
|
Also you need to call requireAuth in apply
void apply(uint64_t code, uint64_t action) {
if ( code == N( mydice ) )
if ( action == N( game ) ) {
requireAuth( N(mydice) );
mydice::Gameplay( currentMessage< mydice::Game >() );
}
}
… On 6 Oct 2017, at 9:35 AM, john rok ***@***.***> wrote:
I think your problem was caused by the following code in Win method:
requireNotice( name );
requireAuth( name );
Remove the above code and have another try, that shall work.
mydice.cpp
void Gameplay(const mydice::Game& game) {
player::Win(game.one);
}
Player.hpp
void Win( AccountName name ) {
requireNotice( name );
requireAuth( name );
auto var = getAccount( name );
var.win += 1;
player::Store( var );
// player::Update( var );
}
> On 28 Sep 2017, at 10:23 PM, Antonio ***@***.*** ***@***.***>> wrote:
>
> I have two contracts.
>
> First - player -( this is contract, creates table and init variable "name" and win = 0.
>
> Second contract -mydice- must change variables in table accounts which contain variables.
>
> The contract player can change itself. But contract number two can not change table in accounts.
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub <#516>, or mute the thread <https://github.com/notifications/unsubscribe-auth/Ad6ZPhNIZgb95ptlgak3FY80GtLXqtLnks5sm6vagaJpZM4PnWRt>.
>
|
@learnforpractice
And add code in mydice.cpp It did not help( |
Hmm, then you should provide more information.
Tell me the commands you ran and the output you got on the eosd.
… On 6 Oct 2017, at 9:43 PM, Antonio ***@***.***> wrote:
@learnforpractice <https://github.com/learnforpractice>
I delete code in player.hpp
requireNotice( name );
requireAuth( name );
And add code in mydice.cpp
requireAuth( N(mydice) );
It did not help(
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#516 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/Ad6ZPiHpsHPKEF0GTQwisQLa3svuvrcGks5spi50gaJpZM4PnWRt>.
|
@learnforpractice |
player variable had to be changed to 1. |
@learnforpractice |
add
account.name = owner;
to getAccount, account will not be changed if load_i64 failed, and in constructor you set name to current code:
Account() {
name = currentCode();
win = 0;
}
That’s the reason why win is always 0.
inline Account getAccount( AccountName owner ) {
Account account;
account.name = owner;
Accounts::get(owner, currentCode(), N( account ), &account, sizeof(account) );
return ( account );
}
Also you need to modify your mydice.abi:
{
"types": [{
"newTypeName": "AccountName",
"type": "Name"
}
],
"structs": [{
"name": "players",
"fields": {
"one": "AccountName"
"two": "AccountName"
}
},{
"name": "void"
},
{
"name": "account",
"fields": {
"name": "AccountName"
"win": "UInt64"
}
}
],
"actions": [{
"action": "game", "type": "players"
},{
"action": "load", "type": "void"
}
]
"tables": [{
"table": "account",
"type": "account",
"indextype": "i64"
}
]
}
And you need to change your command from:
./eosc get table player player account
to
./eosc get table player mydice account
Hope that can solve your problem.
… On 6 Oct 2017, at 10:33 PM, Antonio ***@***.***> wrote:
@learnforpractice <https://github.com/learnforpractice>
mind if, i use one wallet and one pair keys?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#516 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/Ad6ZPm9yKRA7yPbU75yF8TZKybMBHEz0ks5spjpTgaJpZM4PnWRt>.
|
Now mydice once changes the value in the table and does not want to anymore=) |
I can’t quite understand what you said, but I have tested it and It works on my side.
… On 7 Oct 2017, at 12:06 AM, Antonio ***@***.***> wrote:
Now mydice once changes the value in the table and does not want to anymore=)
But already thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#516 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/Ad6ZPiA7_XBzaDmo1ztxuWOtnAiN5_UCks5spk_4gaJpZM4PnWRt>.
|
Could you try to run it more than once? |
The "win" variable need to become greater then 1 |
Yes,it increased by one after push the message.
… On 7 Oct 2017, at 12:29 AM, Antonio ***@***.***> wrote:
The "win" variable need to become greater then 1
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#516 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/Ad6ZPq1YvVfOQcqQpZFvyVbzIXP6yk6Jks5splWEgaJpZM4PnWRt>.
|
I found an error. |
Good to hear that.
… On 7 Oct 2017, at 12:47 AM, Antonio ***@***.***> wrote:
I found an error.
I use Accounts::get(owner, owner, N( account ), &account, sizeof(account) );
but need
Accounts::get(owner, currentCode(), N( account ), &account, sizeof(account) );.
Thanks
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#516 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/Ad6ZPooU4V9p9o6KHfdie0IYEnScASLZks5splm3gaJpZM4PnWRt>.
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have two contracts.
First -
player
-( this is contract, creates table and init variable "name" and win = 0.Second contract -
mydice
- must change variables in table accounts which contain variables.The contract player can change itself. But contract number two can not change table in accounts.
The text was updated successfully, but these errors were encountered: