我想编写需要能够在测试中更改前任帐户的测试。但是我找不到动态更改 VMContext 的方法。
fn get_context(value: u128) -> VMContext {
VMContext {
current_account_id: "alice.near".to_string(),
signer_account_id: "bob.near".to_string(),
signer_account_pk: vec![0, 1, 2],
predecessor_account_id: "carol.near".to_string(),
input: vec![],
block_index: 0,
account_balance: 0,
is_view: false,
storage_usage: 0,
block_timestamp: 123789,
attached_deposit: value,
prepaid_gas: 10u64.pow(9),
random_seed: vec![0, 1, 2],
output_data_receivers: vec![],
}
}
#[test]
fn test_market_creation() {
let mut context = get_context(500000000);
let config = Config::default();
testing_env!(context, config);
let mut contract = MyContract::default();
contract.do_something(); // Fire method with "carol.near" as predecessor
// Switch account to "bob.near"
contract.do_something(); // …Run Code Online (Sandbox Code Playgroud) 我最近一直在学习React Native,但是还没有真正找到一种操作DOM的方法。
我一直在努力做到,如果我单击TouchableHighlight,我的图像会向下移动几个px,但是我还没有设法使其移动,而且老实说,我不知道该怎么做。
我的onclick函数可以正常工作,因为每次单击按钮时它都会返回日志。
到目前为止,我有这个:
export default class MainBody extends Component {
onclick = () => {
console.log('On click works')
};
render() {
return (
<ScrollView showsHorizontalScrollIndicator={false} style={Style.horList} horizontal={true}>
<View >
{/*i need to move this Image down!*/}
<Image source={require("./img/example.png")}/>
<View>
<Text style={Style.peopleInvited}>This is text</Text>
</View>
{/*When clicked on this touchable highlight!*/}
<TouchableHighlight onPress={this.onclick}}>
<Image source={require('./img/moveImg.png')}/>
</TouchableHighlight>
</View>
</ScrollView>
}
Run Code Online (Sandbox Code Playgroud)
如果有人可以帮助我解决这个问题,将不胜感激。非常感谢您的参与!
假设我们像这样初始化,并且用户已经登录:
const near = await window.nearlib.connect(Object.assign({ deps: { keyStore: new window.nearlib.keyStores.BrowserLocalStorageKeyStore() } }, window.nearConfig));
const walletAccount = new window.nearlib.WalletAccount(near);
Run Code Online (Sandbox Code Playgroud)
我希望能够使用以下内容获取帐户的 NEAR 余额:
near.getBalanceOf(walletAccount.getAccountId()).then(...)
Run Code Online (Sandbox Code Playgroud)
或者可能
walletAccount.getBalance().then(...)
Run Code Online (Sandbox Code Playgroud) 我从父级组件触发了一个抽奖动画,问题是由于某种原因,整个抽奖组件层都是可单击的并启动了动画。
这是我正在使用的代码:
constructor(props) {
super(props);
this.state = {
isStopped: true,
isPaused: false,
Animated: 0,
};
this.defaultOptions = {
loop: false,
autoplay: false,
animationData: animationData
};
}
clickHandler = () => {
this.setState({
isStopped: false,
Animated: 0
});
console.log("clicked");
};
render() {
return (
<div id="ethdrop">
<Lottie
className='animation-class'
options={this.defaultOptions}
isStopped={this.state.isStopped}
isPaused={this.state.isPaused}
Animated={this.state.Animated}
/>
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
如果您有任何想法,我找不到任何可能触发此操作的信息,请告诉我。