iOS

简介

GitHub仓库: TP iOS SDK

MiniWallet可以实现对于特定操作,第三方App不需要拉起钱包,直接在应用内部完成,体验更为流畅。

初始化

[TPApi registerAppID:@"tpsdk"];
[TPApi setSeed:@"xxxx" error:nil];
[TPApi setBlockChain:TPBlockChainTypeEOSMainNet nodeUrl:@"http://eosinfo.mytokenpocket.vip" plugNodeUrl:@"http://eosinfo.mytokenpocket.vip"];

Auth

TPAuthObj *auth = [TPAuthObj new];
auth.dappName = @"xxx";
auth.dappIcon = @"https:.../xx.png";
auth.account = "xxxx";
auth.perm = "xxxx";
auth.selectAll = NO;
auth.actions = [linkActions];
[TPApi sendObj:auth resultHandle:^(TPReqType type,NSError *error) {
    // ...        
}];


/// Response ↓
TPRespObj.data
{
    ...,
    "ref" : "TokenPocket",
    "publickey" : "EOS5AvWThdghtNngWP4UcNi9DL6kF7Mnv2ccO",
    "sign" : "SIG_K1_JyCJtV9vqwxtyEt68UhUibkg1CmRjxtG6zkZwE...",
    "timestamp" : "1554266633",
}

发起交易

  • 构建数据,将操作的action中的permission字段值替换成调用auth传递的perm字段。

  • 调用TPApi perm:(NSString *)perm isLinkActions:(NSArray<TPLinkAction *> *)actions account:(NSString *)account completion:(void (^)(BOOL permExisted,BOOL linked,NSError *error))completion检查action绑定状态。

  • 如果第二步绑定成功,则直接调用'Auth'。

  • 如果第二步绑定失败,则需要开发者将permission字段替换成active或者owner,以便拉起钱包执行操作。

方法说明

修改seed

+ (void)resetSeed:(NSString *)seed newSeed:(NSString *)newSeed error:(NSError **)error;

获取已授权账号信息

+ (NSArray<NSString *> *)getAccounts;

检查权限是否存在

+ (void)isPermExist:(NSString *)perm account:(NSString *)account completion:(void (^)(BOOL exist,NSError *error))completion;
+ (void)perm:(NSString *)perm isLinkActions:(NSArray<TPLinkAction *> *)actions account:(NSString *)account completion:(void (^)(BOOL permExisted,BOOL linked,NSError *error))completion;

清除本地授权

+ (BOOL)clearAuth:(NSString *)account;

Last updated